Built motion from commit a9fb64cc6defd8fb3a5cc199221f878e91c0e969. Version 3.0.0...
[motion-next.git] / server / api / mailAccount / mailAccount.controller.js
1 const a394_0x725d=['server/files/attachments','MailServerIn','MailMessage','Pause','model','UserProfileResource','index','userMailAccount:remove','Owner','sort','cservice','YYYY-MM-DD\x20HH:mm:ss','internal','../../rediscache','defaults','SendMail','addApplications','attachments','getImap','offset','Contacts','authentication','nolimit','DESC','tag','MailAccount','intersection','CmContact','sendMail','bulkCreate','getSmtp','filters','result','secure','status','join','basename','List','format','../../mysqldb','CmList','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','CannedAnswer','MailAccountId','describe','Content-Range','attributes','removeImap','email','findAll','removeAgents','Disposition','isArray','Smtp','json','out','info','UserProfileSection','Imap','create','$gte','error','merge','addInteraction','key','gte','register','code','where','ListId','role','util','../../components/parsers/qs','order','Unable\x20to\x20retrieve\x20the\x20current\x20user','removeSmtp','stack','fieldName','send','stringify','user','getAgents','count','map','auth','updatedAt','catch','isNil','emit','sequelize','type','addDisposition','%s\x20<%s>','getApplications','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','removeDispositions','jayson/promise','password','request\x20sent','get','ids','../../config/environment','removeAnswers','MailAccounts','fullname','verifySmtp','active','VerifySmtp','./mailAccount.socket','show','fields','destroy','then','description','host','MailInteraction','update','pick','path','VIRTUAL','MailApplication','body','params','Contact','setImap','from','name','undefined','like','setSmtp','split','userProfileId','query','filter','lodash','set','messageId','cpassword','api','rows','length','MailAccount,\x20%s,\x20%s','message','include','end','debug','moment','addSmtp','mandatoryDispositionPause','Interaction','root','findOne','List\x20not\x20found','transaction','service','pass','port','addAgents','sendStatus','cuser','http','MailServerOut','addAnswer','options','limit','includeAll','keys','rawAttributes','addImap','client','MailAccount,\x20%s,\x20%s,\x20%s'];(function(_0x306e95,_0x725d48){const _0x5bcc43=function(_0x3b77e4){while(--_0x3b77e4){_0x306e95['push'](_0x306e95['shift']());}};_0x5bcc43(++_0x725d48);}(a394_0x725d,0xe7));const a394_0x5bcc=function(_0x306e95,_0x725d48){_0x306e95=_0x306e95-0x0;let _0x5bcc43=a394_0x725d[_0x306e95];return _0x5bcc43;};const _0x512a11=a394_0x5bcc;'use strict';const moment=require(_0x512a11('0x56')),util=require(_0x512a11('0xb')),path=require(_0x512a11('0x3a')),_=require(_0x512a11('0x4a')),{getSocket}=require(_0x512a11('0x7c')),socket=getSocket(),qs=require(_0x512a11('0xc')),logger=require('../../config/logger')(_0x512a11('0x4e')),config=require(_0x512a11('0x29')),db=require(_0x512a11('0x96'))['db'],{Op,ValidationError}=require(_0x512a11('0x1d'));require(_0x512a11('0x30'))[_0x512a11('0x6')](socket);const jayson=require(_0x512a11('0x24')),client=jayson[_0x512a11('0x6d')][_0x512a11('0x64')]({'port':0x232b});function respondWithRpcPromise(_0x3b77e4,_0x277ac7,_0x5bd6d6,_0x29dcd9){return new Promise(function(_0x2f0a4c,_0x18eef7){const _0x5222f7=a394_0x5bcc,_0x8bd329=_0x29dcd9||client;return _0x8bd329['request'](_0x3b77e4,_0x5bd6d6)[_0x5222f7('0x34')](function(_0x4eb9f7){const _0x331696=_0x5222f7;logger[_0x331696('0xa7')](_0x331696('0x51'),_0x277ac7,_0x331696('0x26')),logger[_0x331696('0x55')](_0x331696('0x6e'),_0x277ac7,_0x331696('0x26'),JSON[_0x331696('0x13')](_0x4eb9f7));if(_0x4eb9f7['error']){if(_0x4eb9f7[_0x331696('0x1')][_0x331696('0x7')]===0x1f4)return logger['error'](_0x331696('0x51'),_0x277ac7,_0x4eb9f7[_0x331696('0x1')][_0x331696('0x52')]),_0x18eef7(_0x4eb9f7[_0x331696('0x1')][_0x331696('0x52')]);return logger[_0x331696('0x1')](_0x331696('0x51'),_0x277ac7,_0x4eb9f7[_0x331696('0x1')][_0x331696('0x52')]),_0x2f0a4c(_0x4eb9f7['error'][_0x331696('0x52')]);}else logger[_0x331696('0xa7')](_0x331696('0x51'),_0x277ac7,_0x331696('0x26')),_0x2f0a4c(_0x4eb9f7[_0x331696('0x8f')][_0x331696('0x52')]);})['catch'](function(_0x2297e2){const _0x37ecb3=_0x5222f7;logger[_0x37ecb3('0x1')](_0x37ecb3('0x51'),_0x277ac7,_0x2297e2),_0x18eef7(_0x2297e2);});});}function respondWithStatusCode(_0x2fab23,_0x459f76){return _0x459f76=_0x459f76||0xcc,function(_0x320667){const _0x19fa82=a394_0x5bcc;if(_0x320667)return _0x2fab23[_0x19fa82('0x62')](_0x459f76);return _0x2fab23[_0x19fa82('0x91')](_0x459f76)[_0x19fa82('0x54')]();};}function respondWithResult(_0x45e70b,_0x41a07d){return _0x41a07d=_0x41a07d||0xc8,function(_0xd5cfd8){const _0x166840=a394_0x5bcc;if(_0xd5cfd8)return _0x45e70b['status'](_0x41a07d)[_0x166840('0xa5')](_0xd5cfd8);};}function respondWithFilteredResult(_0x51ed17,_0x3c93a0){return function(_0x1a11c3){const _0x5ae982=a394_0x5bcc;if(_0x1a11c3){const _0x917325=_0x1a11c3[_0x5ae982('0x16')],_0x34ab61=_0x3c93a0[_0x5ae982('0x82')];let _0x4f8ecf=_0x3c93a0[_0x5ae982('0x82')]+_0x3c93a0[_0x5ae982('0x68')],_0x2f4df5;return _0x4f8ecf>=_0x917325?(_0x4f8ecf=_0x917325,_0x2f4df5=0xc8):_0x2f4df5=0xce,_0x51ed17[_0x5ae982('0x91')](_0x2f4df5),_0x51ed17[_0x5ae982('0x4b')](_0x5ae982('0x9c'),_0x34ab61+'-'+_0x4f8ecf+'/'+_0x917325)[_0x5ae982('0xa5')](_0x1a11c3);}return null;};}function saveUpdates(_0x552612){return function(_0x3d0952){const _0x2f3613=a394_0x5bcc;if(_0x3d0952)return _0x3d0952[_0x2f3613('0x38')](_0x552612)[_0x2f3613('0x34')](function(_0x243b11){return _0x243b11;});return null;};}function removeEntity(_0x1874f7){return function(_0x41db1b){const _0x4f3d67=a394_0x5bcc;if(_0x41db1b)return _0x41db1b[_0x4f3d67('0x33')]()[_0x4f3d67('0x34')](function(){const _0x500cf7=_0x4f3d67,_0x1fc141=_0x41db1b[_0x500cf7('0x27')]({'plain':!![]}),_0x348be6=_0x500cf7('0x2b');return db[_0x500cf7('0x74')]['destroy']({'where':{'type':_0x348be6,'resourceId':_0x1fc141['id']}})['then'](function(){return _0x41db1b;});})[_0x4f3d67('0x34')](function(){const _0x4ed4fd=_0x4f3d67;_0x1874f7[_0x4ed4fd('0x91')](0xcc)['end']();});};}function handleEntityNotFound(_0x260f19){return function(_0x4146d7){return!_0x4146d7&&_0x260f19['sendStatus'](0x194),_0x4146d7;};}function handleError(_0x2bf660,_0x26376f){return _0x26376f=_0x26376f||0x1f4,function(_0x32c8a8){const _0x29620f=a394_0x5bcc;logger['error'](_0x32c8a8[_0x29620f('0x10')]),_0x32c8a8[_0x29620f('0x42')]&&delete _0x32c8a8[_0x29620f('0x42')],_0x2bf660['status'](_0x26376f)[_0x29620f('0x12')](_0x32c8a8);};}exports[_0x512a11('0x75')]=function(_0xab1c0e,_0x585ae4){const _0x41acc7=_0x512a11;let _0x269d74={'include':[{'model':db['MailServerIn'],'as':'Imap'},{'model':db[_0x41acc7('0x65')],'as':_0x41acc7('0xa4')},{'model':db[_0x41acc7('0x72')],'as':'mandatoryDispositionPause'}]};const _0x48001a={},_0xd54248={'count':0x0,'rows':[]},_0xc8403e=_[_0x41acc7('0x17')](db[_0x41acc7('0x88')][_0x41acc7('0x6b')],function(_0x5ef76c){const _0x52ba80=_0x41acc7;return{'name':_0x5ef76c[_0x52ba80('0x11')],'type':_0x5ef76c[_0x52ba80('0x1e')]['key']};});_0x48001a['model']=_[_0x41acc7('0x17')](_0xc8403e,'name'),_0x48001a[_0x41acc7('0x48')]=_[_0x41acc7('0x6a')](_0xab1c0e[_0x41acc7('0x48')]),_0x48001a[_0x41acc7('0x8e')]=_[_0x41acc7('0x89')](_0x48001a[_0x41acc7('0x73')],_0x48001a[_0x41acc7('0x48')]),_0x269d74[_0x41acc7('0x9d')]=_[_0x41acc7('0x89')](_0x48001a[_0x41acc7('0x73')],qs[_0x41acc7('0x32')](_0xab1c0e['query'][_0x41acc7('0x32')])),_0x269d74['attributes']=_0x269d74['attributes'][_0x41acc7('0x50')]?_0x269d74[_0x41acc7('0x9d')]:_0x48001a['model'];typeof _0xab1c0e[_0x41acc7('0x48')][_0x41acc7('0x85')]===_0x41acc7('0x43')&&(_0x269d74[_0x41acc7('0x68')]=qs[_0x41acc7('0x68')](_0xab1c0e[_0x41acc7('0x48')]['limit']),_0x269d74[_0x41acc7('0x82')]=qs[_0x41acc7('0x82')](_0xab1c0e['query'][_0x41acc7('0x82')]));_0x269d74[_0x41acc7('0xd')]=qs[_0x41acc7('0x78')](_0xab1c0e['query'][_0x41acc7('0x78')]),_0x269d74['where']=qs[_0x41acc7('0x8e')](_[_0x41acc7('0x39')](_0xab1c0e[_0x41acc7('0x48')],_0x48001a[_0x41acc7('0x8e')]),_0xc8403e);_0xab1c0e[_0x41acc7('0x48')][_0x41acc7('0x49')]&&(_0x269d74[_0x41acc7('0x8')]=_['merge'](_0x269d74[_0x41acc7('0x8')],{[Op['or']]:_[_0x41acc7('0x17')](_0xc8403e,function(_0x1cfd42){const _0x494609=_0x41acc7;if(_0x1cfd42[_0x494609('0x1e')]!==_0x494609('0x3b')){const _0x4b93e7={};return _0x4b93e7[_0x1cfd42[_0x494609('0x42')]]={[Op['like']]:'%'+_0xab1c0e[_0x494609('0x48')][_0x494609('0x49')]+'%'},_0x4b93e7;}})}));_0x269d74=_[_0x41acc7('0x2')]({},_0x269d74,_0xab1c0e[_0x41acc7('0x67')]);const _0x1c54fe={'where':_0x269d74[_0x41acc7('0x8')]};return db[_0x41acc7('0x88')][_0x41acc7('0x16')](_0x1c54fe)[_0x41acc7('0x34')](function(_0x108d03){const _0x5300e1=_0x41acc7;return _0xd54248[_0x5300e1('0x16')]=_0x108d03,_0xab1c0e[_0x5300e1('0x48')]['includeAll']&&(_0x269d74['include']=[{'all':!![]}]),db['MailAccount'][_0x5300e1('0xa0')](_0x269d74);})[_0x41acc7('0x34')](function(_0x1b2544){const _0x1b8d75=_0x41acc7;return _0xd54248[_0x1b8d75('0x4f')]=_0x1b2544,_0xd54248;})['then'](respondWithFilteredResult(_0x585ae4,_0x269d74))[_0x41acc7('0x1a')](handleError(_0x585ae4,null));},exports[_0x512a11('0x31')]=function(_0x13c3eb,_0x50586f){const _0x37d7dd=_0x512a11;let _0x2d57b9={'raw':![],'where':{'id':_0x13c3eb[_0x37d7dd('0x3e')]['id']},'include':[{'model':db[_0x37d7dd('0x70')],'as':'Imap'},{'model':db[_0x37d7dd('0x65')],'as':_0x37d7dd('0xa4')},{'model':db['Pause'],'as':_0x37d7dd('0x58')}]};const _0x19cf73={};return _0x19cf73['model']=_['keys'](db[_0x37d7dd('0x88')][_0x37d7dd('0x6b')]),_0x19cf73['query']=_['keys'](_0x13c3eb[_0x37d7dd('0x48')]),_0x19cf73[_0x37d7dd('0x8e')]=_[_0x37d7dd('0x89')](_0x19cf73[_0x37d7dd('0x73')],_0x19cf73['query']),_0x2d57b9[_0x37d7dd('0x9d')]=_[_0x37d7dd('0x89')](_0x19cf73['model'],qs[_0x37d7dd('0x32')](_0x13c3eb[_0x37d7dd('0x48')][_0x37d7dd('0x32')])),_0x2d57b9['attributes']=_0x2d57b9[_0x37d7dd('0x9d')][_0x37d7dd('0x50')]?_0x2d57b9[_0x37d7dd('0x9d')]:_0x19cf73[_0x37d7dd('0x73')],_0x13c3eb[_0x37d7dd('0x48')][_0x37d7dd('0x69')]&&(_0x2d57b9[_0x37d7dd('0x53')]=[{'all':!![]}]),_0x2d57b9=_['merge']({},_0x2d57b9,_0x13c3eb[_0x37d7dd('0x67')]),db['MailAccount']['findOne'](_0x2d57b9)['then'](handleEntityNotFound(_0x50586f,null))['then'](respondWithResult(_0x50586f,null))[_0x37d7dd('0x1a')](handleError(_0x50586f,null));},exports[_0x512a11('0x38')]=function(_0x1e1d71,_0x401d41){const _0x1280ab=_0x512a11;return _0x1e1d71['body']['id']&&delete _0x1e1d71['body']['id'],db[_0x1280ab('0x88')][_0x1280ab('0x5b')]({'where':{'id':_0x1e1d71[_0x1280ab('0x3e')]['id']},'include':[{'model':db['MailServerIn'],'as':_0x1280ab('0xa9')},{'model':db['MailServerOut'],'as':_0x1280ab('0xa4')},{'model':db[_0x1280ab('0x72')],'as':_0x1280ab('0x58')}]})['then'](handleEntityNotFound(_0x401d41,null))[_0x1280ab('0x34')](saveUpdates(_0x1e1d71[_0x1280ab('0x3d')],null))[_0x1280ab('0x34')](function(_0x2aa041){const _0x4fd1dd=_0x1280ab;if(_0x2aa041&&_0x1e1d71['body'][_0x4fd1dd('0xa9')])return db['MailServerIn'][_0x4fd1dd('0x38')](_0x1e1d71[_0x4fd1dd('0x3d')][_0x4fd1dd('0xa9')],{'where':{'MailAccountId':_0x2aa041['id']}})[_0x4fd1dd('0x34')](function(){return _0x2aa041;});return _0x2aa041;})[_0x1280ab('0x34')](function(_0x994f84){const _0x3c55e9=_0x1280ab;if(_0x994f84&&_0x1e1d71['body']['Smtp'])return db[_0x3c55e9('0x65')][_0x3c55e9('0x38')](_0x1e1d71['body']['Smtp'],{'where':{'MailAccountId':_0x994f84['id']}})[_0x3c55e9('0x34')](function(){return _0x994f84;});return _0x994f84;})[_0x1280ab('0x34')](respondWithResult(_0x401d41,null))['catch'](handleError(_0x401d41,null));},exports[_0x512a11('0x9b')]=function(_0x4f0dc4,_0x55dcf7){const _0x2ba785=_0x512a11;return db[_0x2ba785('0x88')][_0x2ba785('0x9b')]()[_0x2ba785('0x34')](respondWithResult(_0x55dcf7,null))[_0x2ba785('0x1a')](handleError(_0x55dcf7,null));},exports[_0x512a11('0x1f')]=function(_0x1b686e,_0x1a8879){const _0x160f0e=_0x512a11;return _0x1b686e[_0x160f0e('0x3d')]['id']&&delete _0x1b686e[_0x160f0e('0x3d')]['id'],db[_0x160f0e('0x88')]['findOne']({'where':{'id':_0x1b686e[_0x160f0e('0x3e')]['id']}})[_0x160f0e('0x34')](handleEntityNotFound(_0x1a8879,null))['then'](function(_0x4b91f1){const _0x33f36b=_0x160f0e;if(_0x4b91f1)return _0x1b686e['body'][_0x33f36b('0x9a')]=_0x4b91f1['id'],db[_0x33f36b('0xa2')][_0x33f36b('0xaa')](_0x1b686e['body']);})[_0x160f0e('0x34')](respondWithResult(_0x1a8879,null))['catch'](handleError(_0x1a8879,null));},exports['getDispositions']=function(_0x51edfa,_0x9e2fda){const _0x32a67e=_0x512a11;let _0x3bd9d2={'raw':![],'where':{}};const _0x32195e={},_0x2f86a6={'count':0x0,'rows':[]};return db[_0x32a67e('0x88')][_0x32a67e('0x5b')]({'where':{'id':_0x51edfa[_0x32a67e('0x3e')]['id']}})['then'](handleEntityNotFound(_0x9e2fda,null))[_0x32a67e('0x34')](function(_0x4913ab){const _0xd36cb5=_0x32a67e;if(_0x4913ab)return _0x32195e[_0xd36cb5('0x73')]=_[_0xd36cb5('0x6a')](db[_0xd36cb5('0xa2')]['rawAttributes']),_0x32195e[_0xd36cb5('0x48')]=_['keys'](_0x51edfa[_0xd36cb5('0x48')]),_0x32195e[_0xd36cb5('0x8e')]=_[_0xd36cb5('0x89')](_0x32195e[_0xd36cb5('0x73')],_0x32195e['query']),_0x3bd9d2[_0xd36cb5('0x9d')]=_[_0xd36cb5('0x89')](_0x32195e[_0xd36cb5('0x73')],qs[_0xd36cb5('0x32')](_0x51edfa[_0xd36cb5('0x48')][_0xd36cb5('0x32')])),_0x3bd9d2[_0xd36cb5('0x9d')]=_0x3bd9d2[_0xd36cb5('0x9d')][_0xd36cb5('0x50')]?_0x3bd9d2['attributes']:_0x32195e[_0xd36cb5('0x73')],typeof _0x51edfa[_0xd36cb5('0x48')][_0xd36cb5('0x85')]==='undefined'&&(_0x3bd9d2[_0xd36cb5('0x68')]=qs[_0xd36cb5('0x68')](_0x51edfa[_0xd36cb5('0x48')][_0xd36cb5('0x68')]),_0x3bd9d2[_0xd36cb5('0x82')]=qs[_0xd36cb5('0x82')](_0x51edfa[_0xd36cb5('0x48')]['offset'])),_0x3bd9d2[_0xd36cb5('0xd')]=qs[_0xd36cb5('0x78')](_0x51edfa[_0xd36cb5('0x48')][_0xd36cb5('0x78')]),_0x3bd9d2[_0xd36cb5('0x8')]=qs[_0xd36cb5('0x8e')](_['pick'](_0x51edfa[_0xd36cb5('0x48')],_0x32195e['filters'])),_0x3bd9d2[_0xd36cb5('0x8')][_0xd36cb5('0x9a')]=_0x4913ab['id'],_0x51edfa[_0xd36cb5('0x48')]['filter']&&(_0x3bd9d2[_0xd36cb5('0x8')]=_[_0xd36cb5('0x2')](_0x3bd9d2[_0xd36cb5('0x8')],{[Op['or']]:_[_0xd36cb5('0x17')](_0x3bd9d2[_0xd36cb5('0x9d')],function(_0x1a92fa){const _0x5233d3=_0xd36cb5,_0x40318d={};return _0x40318d[_0x1a92fa]={[Op[_0x5233d3('0x44')]]:'%'+_0x51edfa[_0x5233d3('0x48')][_0x5233d3('0x49')]+'%'},_0x40318d;})})),_0x3bd9d2=_[_0xd36cb5('0x2')]({},_0x3bd9d2,_0x51edfa[_0xd36cb5('0x67')]),db[_0xd36cb5('0xa2')][_0xd36cb5('0x16')]({'where':_0x3bd9d2[_0xd36cb5('0x8')]})[_0xd36cb5('0x34')](function(_0x26a436){const _0x5de193=_0xd36cb5;return _0x2f86a6['count']=_0x26a436,_0x51edfa[_0x5de193('0x48')]['includeAll']&&(_0x3bd9d2[_0x5de193('0x53')]=[{'all':!![]}]),db[_0x5de193('0xa2')][_0x5de193('0xa0')](_0x3bd9d2);})[_0xd36cb5('0x34')](function(_0x11ec97){return _0x2f86a6['rows']=_0x11ec97,_0x2f86a6;});})[_0x32a67e('0x34')](respondWithFilteredResult(_0x9e2fda,_0x3bd9d2))[_0x32a67e('0x1a')](handleError(_0x9e2fda,null));},exports[_0x512a11('0x23')]=function(_0x276380,_0x1c72db){const _0x2ae7dd=_0x512a11;return db[_0x2ae7dd('0x88')][_0x2ae7dd('0x5b')]({'where':{'id':_0x276380[_0x2ae7dd('0x3e')]['id']}})['then'](handleEntityNotFound(_0x1c72db,null))[_0x2ae7dd('0x34')](function(_0x2e727a){const _0x29abba=_0x2ae7dd;if(_0x2e727a)return _0x2e727a[_0x29abba('0x23')](_0x276380[_0x29abba('0x48')][_0x29abba('0x28')]);})['then'](respondWithStatusCode(_0x1c72db,null))[_0x2ae7dd('0x1a')](handleError(_0x1c72db,null));},exports[_0x512a11('0x66')]=function(_0x24d09e,_0x3b93c8){const _0x4fec25=_0x512a11;return _0x24d09e[_0x4fec25('0x3d')]['id']&&delete _0x24d09e[_0x4fec25('0x3d')]['id'],db[_0x4fec25('0x88')]['findOne']({'where':{'id':_0x24d09e[_0x4fec25('0x3e')]['id']}})[_0x4fec25('0x34')](handleEntityNotFound(_0x3b93c8,null))[_0x4fec25('0x34')](function(_0x525ede){const _0x52f1ad=_0x4fec25;if(_0x525ede)return _0x24d09e[_0x52f1ad('0x3d')][_0x52f1ad('0x9a')]=_0x525ede['id'],db[_0x52f1ad('0x99')][_0x52f1ad('0xaa')](_0x24d09e['body']);})['then'](respondWithResult(_0x3b93c8,null))[_0x4fec25('0x1a')](handleError(_0x3b93c8,null));},exports['getAnswers']=function(_0x4facfc,_0x5704a5){const _0x407080=_0x512a11;let _0x143b40={'raw':![],'where':{}};const _0x195901={},_0x187803={'count':0x0,'rows':[]};return db[_0x407080('0x88')][_0x407080('0x5b')]({'where':{'id':_0x4facfc[_0x407080('0x3e')]['id']}})[_0x407080('0x34')](handleEntityNotFound(_0x5704a5,null))[_0x407080('0x34')](function(_0x133ae9){const _0x11582e=_0x407080;if(_0x133ae9)return _0x195901[_0x11582e('0x73')]=_[_0x11582e('0x6a')](db[_0x11582e('0x99')][_0x11582e('0x6b')]),_0x195901[_0x11582e('0x48')]=_[_0x11582e('0x6a')](_0x4facfc[_0x11582e('0x48')]),_0x195901[_0x11582e('0x8e')]=_[_0x11582e('0x89')](_0x195901[_0x11582e('0x73')],_0x195901[_0x11582e('0x48')]),_0x143b40[_0x11582e('0x9d')]=_['intersection'](_0x195901['model'],qs[_0x11582e('0x32')](_0x4facfc[_0x11582e('0x48')]['fields'])),_0x143b40[_0x11582e('0x9d')]=_0x143b40['attributes'][_0x11582e('0x50')]?_0x143b40[_0x11582e('0x9d')]:_0x195901[_0x11582e('0x73')],typeof _0x4facfc[_0x11582e('0x48')]['nolimit']===_0x11582e('0x43')&&(_0x143b40[_0x11582e('0x68')]=qs[_0x11582e('0x68')](_0x4facfc[_0x11582e('0x48')][_0x11582e('0x68')]),_0x143b40['offset']=qs[_0x11582e('0x82')](_0x4facfc['query'][_0x11582e('0x82')])),_0x143b40[_0x11582e('0xd')]=qs[_0x11582e('0x78')](_0x4facfc[_0x11582e('0x48')][_0x11582e('0x78')]),_0x143b40[_0x11582e('0x8')]=qs['filters'](_[_0x11582e('0x39')](_0x4facfc['query'],_0x195901['filters'])),_0x143b40[_0x11582e('0x8')][_0x11582e('0x9a')]=_0x133ae9['id'],_0x4facfc[_0x11582e('0x48')]['filter']&&(_0x143b40[_0x11582e('0x8')]=_[_0x11582e('0x2')](_0x143b40[_0x11582e('0x8')],{[Op['or']]:_[_0x11582e('0x17')](_0x143b40['attributes'],function(_0x5951ac){const _0x3b9051=_0x11582e,_0x20d251={};return _0x20d251[_0x5951ac]={[Op[_0x3b9051('0x44')]]:'%'+_0x4facfc[_0x3b9051('0x48')][_0x3b9051('0x49')]+'%'},_0x20d251;})})),_0x143b40=_[_0x11582e('0x2')]({},_0x143b40,_0x4facfc[_0x11582e('0x67')]),db[_0x11582e('0x99')]['count']({'where':_0x143b40[_0x11582e('0x8')]})['then'](function(_0x3d18c7){const _0x1ada26=_0x11582e;return _0x187803[_0x1ada26('0x16')]=_0x3d18c7,_0x4facfc[_0x1ada26('0x48')][_0x1ada26('0x69')]&&(_0x143b40[_0x1ada26('0x53')]=[{'all':!![]}]),db[_0x1ada26('0x99')][_0x1ada26('0xa0')](_0x143b40);})['then'](function(_0x52de48){const _0x3f29c8=_0x11582e;return _0x187803[_0x3f29c8('0x4f')]=_0x52de48,_0x187803;});})[_0x407080('0x34')](respondWithFilteredResult(_0x5704a5,_0x143b40))['catch'](handleError(_0x5704a5,null));},exports[_0x512a11('0x2a')]=function(_0x44318c,_0x487974){const _0x5cefce=_0x512a11;return db[_0x5cefce('0x88')][_0x5cefce('0x5b')]({'where':{'id':_0x44318c[_0x5cefce('0x3e')]['id']}})[_0x5cefce('0x34')](handleEntityNotFound(_0x487974,null))[_0x5cefce('0x34')](function(_0x3d3af7){const _0x17e2c9=_0x5cefce;if(_0x3d3af7)return _0x3d3af7[_0x17e2c9('0x2a')](_0x44318c[_0x17e2c9('0x48')][_0x17e2c9('0x28')]);})['then'](respondWithStatusCode(_0x487974,null))[_0x5cefce('0x1a')](handleError(_0x487974,null));},exports[_0x512a11('0xaa')]=function(_0x46d9c9,_0x1d8544){const _0x2b8271=_0x512a11,_0x5f1c21={'name':_0x46d9c9[_0x2b8271('0x3d')]['name'],'key':_0x46d9c9['body'][_0x2b8271('0x4')],'email':_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x9f')],'ListId':_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x9')],'active':!_['isNil'](_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x2e')])?_0x46d9c9[_0x2b8271('0x3d')]['active']:!![],'description':_0x46d9c9['body'][_0x2b8271('0x35')]||null,'Imap':{},'Smtp':{}};return _['isNil'](_0x46d9c9[_0x2b8271('0x3d')]['cservice'])?(_0x46d9c9[_0x2b8271('0x3d')]['cauthentication']?(_0x5f1c21[_0x2b8271('0xa9')][_0x2b8271('0x14')]=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x63')],_0x5f1c21[_0x2b8271('0xa4')][_0x2b8271('0x14')]=_0x46d9c9[_0x2b8271('0x3d')]['cuser'],_0x5f1c21[_0x2b8271('0xa9')][_0x2b8271('0x25')]=_0x46d9c9['body']['cpassword'],_0x5f1c21[_0x2b8271('0xa4')][_0x2b8271('0x5f')]=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x4d')]):(_0x5f1c21[_0x2b8271('0xa9')]['authentication']=![],_0x5f1c21[_0x2b8271('0xa4')][_0x2b8271('0x84')]=![]),_0x5f1c21[_0x2b8271('0xa9')][_0x2b8271('0x36')]=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0xa9')][_0x2b8271('0x36')],_0x5f1c21[_0x2b8271('0xa9')][_0x2b8271('0x60')]=_0x46d9c9['body'][_0x2b8271('0xa9')][_0x2b8271('0x60')],_0x5f1c21[_0x2b8271('0xa4')][_0x2b8271('0x36')]=_0x46d9c9[_0x2b8271('0x3d')]['Smtp'][_0x2b8271('0x36')],_0x5f1c21['Smtp']['port']=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0xa4')][_0x2b8271('0x60')]):(_0x5f1c21[_0x2b8271('0xa9')][_0x2b8271('0x5e')]=_0x46d9c9[_0x2b8271('0x3d')]['cservice'],_0x5f1c21[_0x2b8271('0xa4')]['service']=_0x46d9c9['body'][_0x2b8271('0x79')],_0x5f1c21['Imap'][_0x2b8271('0x14')]=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x63')],_0x5f1c21[_0x2b8271('0xa4')]['user']=_0x46d9c9['body']['cuser'],_0x5f1c21[_0x2b8271('0xa9')]['password']=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x4d')],_0x5f1c21[_0x2b8271('0xa4')][_0x2b8271('0x5f')]=_0x46d9c9[_0x2b8271('0x3d')][_0x2b8271('0x4d')]),db['MailAccount'][_0x2b8271('0xaa')](_0x5f1c21,{'include':[{'model':db['MailServerOut'],'as':_0x2b8271('0xa4')},{'model':db['MailServerIn'],'as':'Imap'}]})[_0x2b8271('0x34')](function(_0x10d954){const _0x4c1b06=_0x2b8271,_0x3746f5=_0x46d9c9[_0x4c1b06('0x14')][_0x4c1b06('0x27')]({'plain':!![]});if(!_0x3746f5)throw new Error(_0x4c1b06('0xe'));if(_0x3746f5[_0x4c1b06('0xa')]===_0x4c1b06('0x14')){const _0x2030a0=_0x10d954[_0x4c1b06('0x27')]({'plain':!![]});return db[_0x4c1b06('0xa8')]['findOne']({'where':{'name':_0x4c1b06('0x2b'),'userProfileId':_0x3746f5[_0x4c1b06('0x47')]},'raw':!![]})['then'](function(_0x5cdeaf){const _0x50acd3=_0x4c1b06;return _0x5cdeaf&&_0x5cdeaf['autoAssociation']===0x0?db[_0x50acd3('0x74')]['create']({'name':_0x2030a0[_0x50acd3('0x42')],'resourceId':_0x2030a0['id'],'type':_0x5cdeaf[_0x50acd3('0x42')],'sectionId':_0x5cdeaf['id']},{})[_0x50acd3('0x34')](function(){return _0x10d954;}):_0x10d954;})[_0x4c1b06('0x1a')](function(_0xee24a6){const _0x1de2dd=_0x4c1b06;logger[_0x1de2dd('0x1')](_0x1de2dd('0x98'),_0xee24a6);throw _0xee24a6;});}return _0x10d954;})[_0x2b8271('0x34')](respondWithResult(_0x1d8544,0xc9))[_0x2b8271('0x1a')](handleError(_0x1d8544,null));},exports[_0x512a11('0x81')]=function(_0x4f9e43,_0x58b3a5){const _0x1f016d=_0x512a11;return db[_0x1f016d('0x88')][_0x1f016d('0x5b')]({'where':{'id':_0x4f9e43['params']['id']}})[_0x1f016d('0x34')](handleEntityNotFound(_0x58b3a5,null))[_0x1f016d('0x34')](function(_0xf1ce73){const _0x399566=_0x1f016d;if(_0xf1ce73)return _0xf1ce73[_0x399566('0x81')]();return null;})['then'](respondWithResult(_0x58b3a5,null))[_0x1f016d('0x1a')](handleError(_0x58b3a5,null));},exports[_0x512a11('0x6c')]=function(_0x254976,_0x3def1c){const _0x1df80d=_0x512a11;return _0x254976[_0x1df80d('0x3d')]['id']&&delete _0x254976[_0x1df80d('0x3d')]['id'],db[_0x1df80d('0x88')]['findOne']({'where':{'id':_0x254976['params']['id']}})['then'](handleEntityNotFound(_0x3def1c,null))['then'](function(_0x22027a){const _0x2f981b=_0x1df80d;if(_0x22027a)return _0x254976[_0x2f981b('0x3d')][_0x2f981b('0x9a')]=_0x22027a['id'],db[_0x2f981b('0x70')][_0x2f981b('0xaa')](_0x254976[_0x2f981b('0x3d')]);})[_0x1df80d('0x34')](respondWithResult(_0x3def1c,null))['catch'](handleError(_0x3def1c,null));},exports[_0x512a11('0x9e')]=function(_0x4da397,_0x4bbc61){const _0x3b1519=_0x512a11;return db['MailAccount']['findOne']({'where':{'id':_0x4da397['params']['id']}})['then'](handleEntityNotFound(_0x4bbc61,null))[_0x3b1519('0x34')](function(_0x28d530){const _0x205e0f=_0x3b1519;if(_0x28d530)return _0x28d530[_0x205e0f('0x40')](null);return null;})[_0x3b1519('0x34')](respondWithStatusCode(_0x4bbc61,null))[_0x3b1519('0x1a')](handleError(_0x4bbc61,null));},exports[_0x512a11('0x8d')]=function(_0xe4b9c8,_0x27c3c9){const _0x460da7=_0x512a11;return db['MailAccount'][_0x460da7('0x5b')]({'where':{'id':_0xe4b9c8[_0x460da7('0x3e')]['id']}})[_0x460da7('0x34')](handleEntityNotFound(_0x27c3c9,null))[_0x460da7('0x34')](function(_0x3e9e74){const _0x3e21cd=_0x460da7;if(_0x3e9e74)return _0x3e9e74[_0x3e21cd('0x8d')]();return null;})['then'](respondWithResult(_0x27c3c9,null))[_0x460da7('0x1a')](handleError(_0x27c3c9,null));},exports[_0x512a11('0x57')]=function(_0x5a8b64,_0x2e050e){const _0x5456ec=_0x512a11;return _0x5a8b64['body']['id']&&delete _0x5a8b64[_0x5456ec('0x3d')]['id'],db[_0x5456ec('0x88')][_0x5456ec('0x5b')]({'where':{'id':_0x5a8b64[_0x5456ec('0x3e')]['id']}})[_0x5456ec('0x34')](handleEntityNotFound(_0x2e050e,null))[_0x5456ec('0x34')](function(_0x2333d9){const _0x22f9da=_0x5456ec;if(_0x2333d9)return _0x5a8b64[_0x22f9da('0x3d')][_0x22f9da('0x9a')]=_0x2333d9['id'],db[_0x22f9da('0x65')][_0x22f9da('0xaa')](_0x5a8b64['body']);})['then'](respondWithResult(_0x2e050e,null))[_0x5456ec('0x1a')](handleError(_0x2e050e,null));},exports[_0x512a11('0xf')]=function(_0x4e122f,_0x388a7a){const _0x5639be=_0x512a11;return db[_0x5639be('0x88')][_0x5639be('0x5b')]({'where':{'id':_0x4e122f['params']['id']}})['then'](handleEntityNotFound(_0x388a7a,null))['then'](function(_0x1443a2){const _0x57751d=_0x5639be;if(_0x1443a2)return _0x1443a2[_0x57751d('0x45')](null);return null;})[_0x5639be('0x34')](respondWithStatusCode(_0x388a7a,null))[_0x5639be('0x1a')](handleError(_0x388a7a,null));},exports[_0x512a11('0x3')]=function(_0x3bfe8a,_0x40db23){const _0x5cdea5=_0x512a11;return db[_0x5cdea5('0x37')][_0x5cdea5('0x5b')]({'where':{'id':_0x3bfe8a[_0x5cdea5('0x3e')]['id']}})[_0x5cdea5('0x34')](function(_0xaa8ee1){const _0x5d882b=_0x5cdea5;if(_0xaa8ee1)return _0xaa8ee1[_0x5d882b('0x3')](_0x3bfe8a['body'][_0x5d882b('0x28')],{'through':_['omit'](_0x3bfe8a['body'],[_0x5d882b('0x28'),'id'])});})['then'](respondWithResult(_0x40db23,null))[_0x5cdea5('0x1a')](handleError(_0x40db23,null));},exports['getInteractions']=function(_0x40df81,_0x33b01b){const _0x4ad641=_0x512a11;let _0x2e2c48={'raw':![],'where':{}};const _0x46506b={},_0x3c8039={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x40df81[_0x4ad641('0x3e')]['id']}})[_0x4ad641('0x34')](handleEntityNotFound(_0x33b01b,null))[_0x4ad641('0x34')](function(_0x2eee30){const _0x5757ca=_0x4ad641;if(_0x2eee30)return _0x46506b[_0x5757ca('0x73')]=_[_0x5757ca('0x6a')](db['MailInteraction'][_0x5757ca('0x6b')]),_0x46506b[_0x5757ca('0x48')]=_['keys'](_0x40df81[_0x5757ca('0x48')]),_0x46506b[_0x5757ca('0x8e')]=_[_0x5757ca('0x89')](_0x46506b[_0x5757ca('0x73')],_0x46506b[_0x5757ca('0x48')]),_0x2e2c48[_0x5757ca('0x9d')]=_[_0x5757ca('0x89')](_0x46506b[_0x5757ca('0x73')],qs[_0x5757ca('0x32')](_0x40df81[_0x5757ca('0x48')][_0x5757ca('0x32')])),_0x2e2c48['attributes']=_0x2e2c48[_0x5757ca('0x9d')][_0x5757ca('0x50')]?_0x2e2c48[_0x5757ca('0x9d')]:_0x46506b[_0x5757ca('0x73')],typeof _0x40df81[_0x5757ca('0x48')][_0x5757ca('0x85')]===_0x5757ca('0x43')&&(_0x2e2c48['limit']=qs[_0x5757ca('0x68')](_0x40df81[_0x5757ca('0x48')]['limit']),_0x2e2c48[_0x5757ca('0x82')]=qs[_0x5757ca('0x82')](_0x40df81['query'][_0x5757ca('0x82')])),_0x2e2c48[_0x5757ca('0xd')]=qs[_0x5757ca('0x78')](_0x40df81[_0x5757ca('0x48')]['sort']),_0x2e2c48[_0x5757ca('0x8')]=qs[_0x5757ca('0x8e')](_['pick'](_0x40df81[_0x5757ca('0x48')],_0x46506b[_0x5757ca('0x8e')])),_0x2e2c48[_0x5757ca('0x8')]['MailAccountId']=_0x2eee30['id'],_0x40df81['query'][_0x5757ca('0x49')]&&(_0x2e2c48['where']=_[_0x5757ca('0x2')](_0x2e2c48[_0x5757ca('0x8')],{[Op['or']]:_['map'](_0x2e2c48[_0x5757ca('0x9d')],function(_0x1aee18){const _0x1a7ef7=_0x5757ca,_0x3321b6={};return _0x3321b6[_0x1aee18]={[Op[_0x1a7ef7('0x44')]]:'%'+_0x40df81[_0x1a7ef7('0x48')][_0x1a7ef7('0x49')]+'%'},_0x3321b6;})})),_0x2e2c48=_[_0x5757ca('0x2')]({},_0x2e2c48,_0x40df81[_0x5757ca('0x67')]),db['MailInteraction']['count']({'where':_0x2e2c48[_0x5757ca('0x8')]})[_0x5757ca('0x34')](function(_0x5040c2){const _0x26199c=_0x5757ca;return _0x3c8039[_0x26199c('0x16')]=_0x5040c2,_0x40df81['query'][_0x26199c('0x69')]&&(_0x2e2c48['include']=[{'model':db[_0x26199c('0x8a')],'as':_0x26199c('0x3f'),'required':![]},{'model':db['User'],'as':_0x26199c('0x77'),'attributes':['name',_0x26199c('0x2c'),_0x26199c('0x7b')],'required':![]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0x26199c('0x42'),'color'],'where':_0x40df81[_0x26199c('0x48')][_0x26199c('0x87')]?{'id':_0x40df81[_0x26199c('0x48')][_0x26199c('0x87')]}:undefined,'required':_0x40df81[_0x26199c('0x48')]['tag']?!![]:![]}]),db[_0x26199c('0x37')]['findAll'](_0x2e2c48);})[_0x5757ca('0x34')](function(_0x3ded36){const _0x36c304=_0x5757ca;return _0x3c8039[_0x36c304('0x4f')]=_0x3ded36,_0x3c8039;});})['then'](respondWithFilteredResult(_0x33b01b,_0x2e2c48))[_0x4ad641('0x1a')](handleError(_0x33b01b,null));},exports[_0x512a11('0x7f')]=function(_0x5c3d18,_0x596928){const _0x422e9d=_0x512a11;return db['MailAccount']['findOne']({'where':{'id':_0x5c3d18[_0x422e9d('0x3e')]['id']}})[_0x422e9d('0x34')](handleEntityNotFound(_0x596928,null))['then'](function(_0x26c375){const _0x47c60d=_0x422e9d;if(_0x26c375)return db['sequelize'][_0x47c60d('0x5d')](function(_0x385632){const _0x308e01=_0x47c60d;return db[_0x308e01('0x3c')][_0x308e01('0x33')]({'where':{'MailAccountId':_0x5c3d18[_0x308e01('0x3e')]['id']},'transaction':_0x385632})[_0x308e01('0x34')](function(){const _0x203a74=_0x308e01,_0x5d4c24=_[_0x203a74('0x17')](_0x5c3d18[_0x203a74('0x3d')],function(_0x496d4e){const _0x5a3856=_0x203a74;return _0x496d4e[_0x5a3856('0x9a')]=_0x5c3d18[_0x5a3856('0x3e')]['id'],_0x496d4e;});return db['MailApplication'][_0x203a74('0x8c')](_0x5d4c24,{'transaction':_0x385632});});})[_0x47c60d('0x34')](function(){return db['MailApplication']['findAndCountAll']({'where':{'MailAccountId':_0x5c3d18['params']['id']},'order':'priority'});});})[_0x422e9d('0x34')](respondWithResult(_0x596928,null))[_0x422e9d('0x1a')](handleError(_0x596928,null));},exports[_0x512a11('0x21')]=function(_0x1aff4d,_0x25797d){const _0x3d5ee0=_0x512a11;let _0xfddd86={};const _0x375902={};let _0x2efbab,_0x28cdb1;return db[_0x3d5ee0('0x88')][_0x3d5ee0('0x5b')]({'where':{'id':_0x1aff4d[_0x3d5ee0('0x3e')]['id']}})[_0x3d5ee0('0x34')](handleEntityNotFound(_0x25797d,null))[_0x3d5ee0('0x34')](function(_0xcbd468){const _0x205896=_0x3d5ee0;if(_0xcbd468)return _0x2efbab=_0xcbd468,_0x375902[_0x205896('0x73')]=_[_0x205896('0x6a')](db[_0x205896('0x3c')][_0x205896('0x6b')]),_0x375902[_0x205896('0x48')]=_['keys'](_0x1aff4d[_0x205896('0x48')]),_0x375902['filters']=_[_0x205896('0x89')](_0x375902[_0x205896('0x73')],_0x375902[_0x205896('0x48')]),_0xfddd86[_0x205896('0x9d')]=_['intersection'](_0x375902[_0x205896('0x73')],qs[_0x205896('0x32')](_0x1aff4d['query']['fields'])),_0xfddd86['attributes']=_0xfddd86[_0x205896('0x9d')][_0x205896('0x50')]?_0xfddd86[_0x205896('0x9d')]:_0x375902['model'],_0xfddd86[_0x205896('0xd')]=qs[_0x205896('0x78')](_0x1aff4d[_0x205896('0x48')]['sort']),_0xfddd86[_0x205896('0x8')]=qs[_0x205896('0x8e')](_[_0x205896('0x39')](_0x1aff4d[_0x205896('0x48')],_0x375902[_0x205896('0x8e')])),_0x1aff4d[_0x205896('0x48')][_0x205896('0x49')]&&(_0xfddd86[_0x205896('0x8')]=_[_0x205896('0x2')](_0xfddd86[_0x205896('0x8')],{[Op['or']]:_[_0x205896('0x17')](_0xfddd86[_0x205896('0x9d')],function(_0x17e69b){const _0x5d7385=_0x205896,_0x16754d={};return _0x16754d[_0x17e69b]={[Op[_0x5d7385('0x44')]]:'%'+_0x1aff4d[_0x5d7385('0x48')][_0x5d7385('0x49')]+'%'},_0x16754d;})})),_0xfddd86=_[_0x205896('0x2')]({},_0xfddd86,_0x1aff4d[_0x205896('0x67')]),_0x2efbab[_0x205896('0x21')](_0xfddd86);})[_0x3d5ee0('0x34')](function(_0x52c97a){const _0x21ec43=_0x3d5ee0;if(_0x52c97a)return _0x28cdb1=_0x52c97a[_0x21ec43('0x50')],typeof _0x1aff4d[_0x21ec43('0x48')][_0x21ec43('0x85')]==='undefined'&&(_0xfddd86[_0x21ec43('0x68')]=qs[_0x21ec43('0x68')](_0x1aff4d[_0x21ec43('0x48')][_0x21ec43('0x68')]),_0xfddd86[_0x21ec43('0x82')]=qs[_0x21ec43('0x82')](_0x1aff4d[_0x21ec43('0x48')]['offset'])),_0x2efbab['getApplications'](_0xfddd86);})['then'](function(_0x4a8dc5){if(_0x4a8dc5)return _0x4a8dc5?{'count':_0x28cdb1,'rows':_0x4a8dc5}:null;})[_0x3d5ee0('0x34')](respondWithResult(_0x25797d,null))[_0x3d5ee0('0x1a')](handleError(_0x25797d,null));},exports['getMessages']=function(_0x4cd423,_0x1e83a4){const _0x282798=_0x512a11;let _0x127d00={'raw':!![],'where':{}};const _0x88efa3={},_0x23246c={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x4cd423['params']['id']}})[_0x282798('0x34')](handleEntityNotFound(_0x1e83a4,null))[_0x282798('0x34')](function(_0x4c79b3){const _0x2d2ae3=_0x282798;if(_0x4c79b3){_0x88efa3['model']=_['keys'](db[_0x2d2ae3('0x71')][_0x2d2ae3('0x6b')]),_0x88efa3['query']=_['keys'](_0x4cd423['query']),_0x88efa3[_0x2d2ae3('0x8e')]=_[_0x2d2ae3('0x89')](_0x88efa3['model'],_0x88efa3[_0x2d2ae3('0x48')]),_0x127d00[_0x2d2ae3('0x9d')]=_['intersection'](_0x88efa3[_0x2d2ae3('0x73')],qs['fields'](_0x4cd423[_0x2d2ae3('0x48')][_0x2d2ae3('0x32')])),_0x127d00[_0x2d2ae3('0x9d')]=_0x127d00['attributes'][_0x2d2ae3('0x50')]?_0x127d00[_0x2d2ae3('0x9d')]:_0x88efa3['model'];typeof _0x4cd423['query']['nolimit']===_0x2d2ae3('0x43')&&(_0x127d00[_0x2d2ae3('0x68')]=qs[_0x2d2ae3('0x68')](_0x4cd423['query']['limit']),_0x127d00['offset']=qs[_0x2d2ae3('0x82')](_0x4cd423[_0x2d2ae3('0x48')][_0x2d2ae3('0x82')]));_0x127d00[_0x2d2ae3('0xd')]=qs['sort'](_0x4cd423[_0x2d2ae3('0x48')][_0x2d2ae3('0x78')]),_0x127d00['where']=qs[_0x2d2ae3('0x8e')](_[_0x2d2ae3('0x39')](_0x4cd423[_0x2d2ae3('0x48')],_0x88efa3[_0x2d2ae3('0x8e')])),_0x127d00[_0x2d2ae3('0x8')][_0x2d2ae3('0x9a')]=_0x4c79b3['id'];_0x4cd423[_0x2d2ae3('0x48')][_0x2d2ae3('0x49')]&&(_0x127d00[_0x2d2ae3('0x8')]=_[_0x2d2ae3('0x2')](_0x127d00[_0x2d2ae3('0x8')],{[Op['or']]:_[_0x2d2ae3('0x17')](_0x127d00[_0x2d2ae3('0x9d')],function(_0x4233da){const _0x1f773e=_0x2d2ae3,_0x412da7={};return _0x412da7[_0x4233da]={[Op['like']]:'%'+_0x4cd423['query'][_0x1f773e('0x49')]+'%'},_0x412da7;})}));if(_0x4cd423[_0x2d2ae3('0x48')][_0x2d2ae3('0x0')]){const _0x4fd48c=_0x4cd423[_0x2d2ae3('0x48')][_0x2d2ae3('0x0')][_0x2d2ae3('0x46')](','),_0x3ba79b={};_0x3ba79b[_0x4fd48c[0x0]]={[Op[_0x2d2ae3('0x5')]]:moment(_0x4fd48c[0x1])[_0x2d2ae3('0x95')](_0x2d2ae3('0x7a'))},_0x127d00[_0x2d2ae3('0x8')]=_['merge'](_0x127d00[_0x2d2ae3('0x8')],_0x3ba79b);}return _0x127d00=_[_0x2d2ae3('0x2')]({},_0x127d00,_0x4cd423['options']),db['MailMessage']['count']({'where':_0x127d00['where']})[_0x2d2ae3('0x34')](function(_0x5ddbbc){const _0x359e6f=_0x2d2ae3;return _0x23246c[_0x359e6f('0x16')]=_0x5ddbbc,_0x4cd423['query'][_0x359e6f('0x69')]&&(_0x127d00['include']=[{'all':!![]}]),db[_0x359e6f('0x71')][_0x359e6f('0xa0')](_0x127d00);})['then'](function(_0x22f3dc){const _0x57ac12=_0x2d2ae3;return _0x23246c[_0x57ac12('0x4f')]=_0x22f3dc,_0x23246c;});}})[_0x282798('0x34')](respondWithFilteredResult(_0x1e83a4,_0x127d00))['catch'](handleError(_0x1e83a4,null));},exports[_0x512a11('0x12')]=function(_0x2bb69e,_0x30009c){const _0x2759f5=_0x512a11;let _0xebc34d,_0x39b1c9={},_0x3654d2;return _0x2bb69e[_0x2759f5('0x3d')]['to']&&(_0x3654d2=_0x2bb69e[_0x2759f5('0x3d')]['to']['split'](',')[0x0]),db['MailAccount']['findOne']({'where':{'id':_0x2bb69e['params']['id']},'include':[{'model':db[_0x2759f5('0x97')],'as':_0x2759f5('0x94'),'include':[{'model':db[_0x2759f5('0x8a')],'as':_0x2759f5('0x83'),'where':{'email':_0x3654d2},'limit':0x1,'order':[[_0x2759f5('0x19'),_0x2759f5('0x86')]]}]},{'model':db[_0x2759f5('0x65')],'as':_0x2759f5('0xa4'),'raw':!![]}]})['then'](handleEntityNotFound(_0x30009c,null))[_0x2759f5('0x34')](function(_0x81336f){const _0x219b0f=_0x2759f5;if(_0x81336f){_0xebc34d=_0x81336f;if(_0x81336f[_0x219b0f('0xa4')]){_['isNil'](_0x2bb69e['body']['from'])&&(_0x2bb69e['body'][_0x219b0f('0x41')]=util['format'](_0x219b0f('0x20'),_0x81336f[_0x219b0f('0x42')],_0x81336f[_0x219b0f('0x9f')]||_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x14')]));if(_0x2bb69e[_0x219b0f('0x3d')][_0x219b0f('0x80')]&&_0x2bb69e[_0x219b0f('0x3d')]['attachments']['length'])for(let _0x19dacf=0x0;_0x19dacf<_0x2bb69e[_0x219b0f('0x3d')][_0x219b0f('0x80')][_0x219b0f('0x50')];_0x19dacf+=0x1){_0x2bb69e['body'][_0x219b0f('0x80')][_0x19dacf]={'filename':_0x2bb69e['body'][_0x219b0f('0x80')][_0x19dacf]['name'],'path':path[_0x219b0f('0x92')](config[_0x219b0f('0x5a')],_0x219b0f('0x6f'),_0x2bb69e[_0x219b0f('0x3d')][_0x219b0f('0x80')][_0x19dacf][_0x219b0f('0x93')])};}const _0x377421={'tls':{'rejectUnauthorized':![]}};return _[_0x219b0f('0x1b')](_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x5e')])?(_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x84')]&&(_0x377421['auth']={'user':_0x81336f['Smtp'][_0x219b0f('0x14')],'pass':_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x5f')]}),_0x377421[_0x219b0f('0x36')]=_0x81336f[_0x219b0f('0xa4')]['host'],_0x377421[_0x219b0f('0x60')]=_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x60')],_0x377421[_0x219b0f('0x90')]=_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x90')]):(_0x377421[_0x219b0f('0x5e')]=_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x5e')],_0x377421[_0x219b0f('0x18')]={'user':_0x81336f[_0x219b0f('0xa4')][_0x219b0f('0x14')],'pass':_0x81336f[_0x219b0f('0xa4')]['pass']}),respondWithRpcPromise(_0x219b0f('0x7e'),_0x219b0f('0x8b'),{'account':_0x377421,'message':_0x2bb69e[_0x219b0f('0x3d')]});}else throw new Error('List\x20not\x20found');}})[_0x2759f5('0x34')](function(_0x185df6){const _0xd3e5d2=_0x2759f5;if(_0x185df6){_0x39b1c9=_0x185df6;if(_0xebc34d[_0xd3e5d2('0x94')])return _0xebc34d[_0xd3e5d2('0x94')]['Contacts'][_0xd3e5d2('0x50')]?_0xebc34d[_0xd3e5d2('0x94')][_0xd3e5d2('0x83')][0x0]:db[_0xd3e5d2('0x8a')][_0xd3e5d2('0xaa')](_[_0xd3e5d2('0x7d')](_0x2bb69e[_0xd3e5d2('0x3d')],{'firstName':_0x2bb69e[_0xd3e5d2('0x3d')]['to'],'email':_0x2bb69e[_0xd3e5d2('0x3d')]['to'],'phone':_0x2bb69e[_0xd3e5d2('0x3d')]['to'],'ListId':_0xebc34d[_0xd3e5d2('0x9')]}));else throw new Error(_0xd3e5d2('0x5c'));}})[_0x2759f5('0x34')](function(_0x2ffe06){const _0x260fb0=_0x2759f5;if(_0x2ffe06){let _0x539126={'UserId':_0x2bb69e['user']['id'],'ContactId':_0x2ffe06['id'],'MailAccountId':_0xebc34d['id'],'inReplyTo':_0x39b1c9[_0x260fb0('0x4c')],'to':_0x2bb69e[_0x260fb0('0x3d')]['from'],'cc':_0x2bb69e[_0x260fb0('0x3d')]['cc'],'subject':_0x2bb69e[_0x260fb0('0x3d')]['subject'],'attach':_0x2bb69e[_0x260fb0('0x3d')]['attach'],'firstMsgDirection':'out','lastMsgAt':moment()['format'](_0x260fb0('0x7a')),'lastMsgDirection':_0x260fb0('0xa6'),'lastMsgBody':_0x2bb69e[_0x260fb0('0x3d')]['body'],'Messages':[_['merge'](_0x2bb69e[_0x260fb0('0x3d')],{'messageId':_0x39b1c9[_0x260fb0('0x4c')],'sentAt':moment()[_0x260fb0('0x95')](_0x260fb0('0x7a')),'read':!![],'MailAccountId':_0xebc34d['id'],'UserId':_0x2bb69e['user']['id'],'ContactId':_0x2ffe06['id']})]};return _0x2bb69e[_0x260fb0('0x3d')][_0x260fb0('0x59')]&&(_0x539126=_[_0x260fb0('0x2')](_0x539126,_0x2bb69e[_0x260fb0('0x3d')][_0x260fb0('0x59')])),db[_0x260fb0('0x37')][_0x260fb0('0xaa')](_0x539126,{'include':[{'model':db[_0x260fb0('0x71')],'as':'Messages'}]});}})[_0x2759f5('0x34')](respondWithResult(_0x30009c,null))[_0x2759f5('0x1a')](handleError(_0x30009c,null));},exports['verifySmtp']=function(_0x14eba1,_0x52f56d){const _0x4cb366=_0x512a11;return db[_0x4cb366('0x88')][_0x4cb366('0x5b')]({'where':{'id':_0x14eba1[_0x4cb366('0x3e')]['id']},'include':[{'model':db[_0x4cb366('0x65')],'as':_0x4cb366('0xa4'),'raw':!![]}]})['then'](handleEntityNotFound(_0x52f56d,null))['then'](function(_0x1ed733){const _0x10d743=_0x4cb366;if(_0x1ed733&&_0x1ed733[_0x10d743('0xa4')]){const _0x366b05={'id':_0x1ed733['id'],'tls':{'rejectUnauthorized':![]}};return _0x1ed733[_0x10d743('0xa4')]['service']?_0x366b05['service']=_0x1ed733[_0x10d743('0xa4')][_0x10d743('0x5e')]:(_0x366b05[_0x10d743('0x36')]=_0x1ed733['Smtp']['host'],_0x366b05[_0x10d743('0x60')]=_0x1ed733[_0x10d743('0xa4')][_0x10d743('0x60')],_0x366b05[_0x10d743('0x90')]=_0x1ed733[_0x10d743('0xa4')][_0x10d743('0x90')]),_0x1ed733['Smtp'][_0x10d743('0x84')]&&(_0x366b05[_0x10d743('0x18')]={'user':_0x1ed733[_0x10d743('0xa4')][_0x10d743('0x14')],'pass':_0x1ed733['Smtp'][_0x10d743('0x5f')]}),respondWithRpcPromise(_0x10d743('0x2f'),_0x10d743('0x2d'),{'account':_0x366b05});}})[_0x4cb366('0x34')](respondWithResult(_0x52f56d,null))[_0x4cb366('0x1a')](handleError(_0x52f56d,null));},exports['destroy']=function(_0x139afb,_0x57f164){const _0x5cd8cd=_0x512a11;return db['MailAccount']['findOne']({'where':{'id':_0x139afb[_0x5cd8cd('0x3e')]['id']}})[_0x5cd8cd('0x34')](handleEntityNotFound(_0x57f164,null))['then'](function(_0xa033be){const _0x7017ae=_0x5cd8cd;if(_0xa033be&&_0xa033be['service'])throw new ValidationError(_0x7017ae('0x22'));return _0xa033be;})['then'](removeEntity(_0x57f164,null))['catch'](handleError(_0x57f164,null));},exports[_0x512a11('0x61')]=function(_0xddcb6,_0x3b432f){const _0x3bd1a6=_0x512a11;return db['MailAccount'][_0x3bd1a6('0x5b')]({'where':{'id':_0xddcb6[_0x3bd1a6('0x3e')]['id']}})['then'](function(_0x5d7267){const _0xf6cfd7=_0x3bd1a6;if(_0x5d7267)return _0x5d7267['addAgents'](_0xddcb6[_0xf6cfd7('0x3d')][_0xf6cfd7('0x28')],{'through':_['omit'](_0xddcb6[_0xf6cfd7('0x3d')],[_0xf6cfd7('0x28'),'id'])})[_0xf6cfd7('0x34')](function(_0x567128){const _0xbbf162=_0xf6cfd7;for(let _0x12af24=0x0;_0x12af24<_0xddcb6[_0xbbf162('0x3d')][_0xbbf162('0x28')][_0xbbf162('0x50')];_0x12af24+=0x1){socket[_0xbbf162('0x1c')]('userMailAccount:save',{'UserId':_0xddcb6['body'][_0xbbf162('0x28')][_0x12af24],'MailAccountId':_0xddcb6['params']['id']});}return _0x567128;});})[_0x3bd1a6('0x34')](respondWithResult(_0x3b432f,null))[_0x3bd1a6('0x1a')](handleError(_0x3b432f,null));},exports[_0x512a11('0xa1')]=function(_0x31694a,_0x4f9a07){const _0x223644=_0x512a11;return db[_0x223644('0x88')]['findOne']({'where':{'id':_0x31694a[_0x223644('0x3e')]['id']}})[_0x223644('0x34')](handleEntityNotFound(_0x4f9a07,null))[_0x223644('0x34')](function(_0x882627){const _0x1255d3=_0x223644;if(_0x882627)return _0x882627[_0x1255d3('0xa1')](_0x31694a[_0x1255d3('0x48')][_0x1255d3('0x28')])[_0x1255d3('0x34')](function(){const _0x3dc539=_0x1255d3;if(_[_0x3dc539('0xa3')](_0x31694a[_0x3dc539('0x48')][_0x3dc539('0x28')]))for(let _0x4d4944=0x0;_0x4d4944<_0x31694a[_0x3dc539('0x48')][_0x3dc539('0x28')][_0x3dc539('0x50')];_0x4d4944+=0x1){socket['emit'](_0x3dc539('0x76'),{'UserId':Number(_0x31694a[_0x3dc539('0x48')][_0x3dc539('0x28')][_0x4d4944]),'MailAccountId':Number(_0x31694a[_0x3dc539('0x3e')]['id'])});}else socket[_0x3dc539('0x1c')](_0x3dc539('0x76'),{'UserId':Number(_0x31694a[_0x3dc539('0x48')][_0x3dc539('0x28')]),'MailAccountId':Number(_0x31694a['params']['id'])});});})['then'](respondWithStatusCode(_0x4f9a07,null))[_0x223644('0x1a')](handleError(_0x4f9a07,null));},exports[_0x512a11('0x15')]=function(_0x1e19b6,_0x3acfc5){const _0x11c560=_0x512a11;let _0x2ccb8f={};const _0x47b2db={};let _0x1b77b4,_0x421d98;return db[_0x11c560('0x88')][_0x11c560('0x5b')]({'where':{'id':_0x1e19b6[_0x11c560('0x3e')]['id']}})[_0x11c560('0x34')](handleEntityNotFound(_0x3acfc5,null))[_0x11c560('0x34')](function(_0x2acd9a){const _0x4b794f=_0x11c560;if(_0x2acd9a)return _0x1b77b4=_0x2acd9a,_0x47b2db[_0x4b794f('0x73')]=_[_0x4b794f('0x6a')](db['User'][_0x4b794f('0x6b')]),_0x47b2db[_0x4b794f('0x48')]=_[_0x4b794f('0x6a')](_0x1e19b6['query']),_0x47b2db[_0x4b794f('0x8e')]=_['intersection'](_0x47b2db[_0x4b794f('0x73')],_0x47b2db[_0x4b794f('0x48')]),_0x2ccb8f[_0x4b794f('0x9d')]=_[_0x4b794f('0x89')](_0x47b2db[_0x4b794f('0x73')],qs['fields'](_0x1e19b6[_0x4b794f('0x48')][_0x4b794f('0x32')])),_0x2ccb8f['attributes']=_0x2ccb8f[_0x4b794f('0x9d')][_0x4b794f('0x50')]?_0x2ccb8f[_0x4b794f('0x9d')]:_0x47b2db[_0x4b794f('0x73')],_0x2ccb8f['order']=qs[_0x4b794f('0x78')](_0x1e19b6[_0x4b794f('0x48')][_0x4b794f('0x78')]),_0x2ccb8f[_0x4b794f('0x8')]=qs[_0x4b794f('0x8e')](_['pick'](_0x1e19b6[_0x4b794f('0x48')],_0x47b2db[_0x4b794f('0x8e')])),_0x1e19b6[_0x4b794f('0x48')][_0x4b794f('0x49')]&&(_0x2ccb8f[_0x4b794f('0x8')]=_['merge'](_0x2ccb8f[_0x4b794f('0x8')],{[Op['or']]:_['map'](_0x2ccb8f[_0x4b794f('0x9d')],function(_0x40dd86){const _0x46e647=_0x4b794f,_0x20bd2f={};return _0x20bd2f[_0x40dd86]={[Op[_0x46e647('0x44')]]:'%'+_0x1e19b6[_0x46e647('0x48')][_0x46e647('0x49')]+'%'},_0x20bd2f;})})),_0x2ccb8f=_[_0x4b794f('0x2')]({},_0x2ccb8f,_0x1e19b6[_0x4b794f('0x67')]),_0x1b77b4[_0x4b794f('0x15')](_0x2ccb8f);})['then'](function(_0x1e3acb){const _0x263505=_0x11c560;if(_0x1e3acb)return _0x421d98=_0x1e3acb[_0x263505('0x50')],typeof _0x1e19b6[_0x263505('0x48')][_0x263505('0x85')]===_0x263505('0x43')&&(_0x2ccb8f[_0x263505('0x68')]=qs[_0x263505('0x68')](_0x1e19b6[_0x263505('0x48')]['limit']),_0x2ccb8f[_0x263505('0x82')]=qs['offset'](_0x1e19b6[_0x263505('0x48')][_0x263505('0x82')])),_0x1b77b4[_0x263505('0x15')](_0x2ccb8f);})['then'](function(_0xa88940){if(_0xa88940)return _0xa88940?{'count':_0x421d98,'rows':_0xa88940}:null;})['then'](respondWithResult(_0x3acfc5,null))['catch'](handleError(_0x3acfc5,null));};