Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / services / email / lib / email.js
index 425646b..24c126a 100644 (file)
@@ -1 +1 @@
-const a1316_0x4467=['handleImapEmail','../../../config/logger','handleImapError','undefined','../../../rediscache','name','mailAccount:update','messages','start\x20email\x20channel','catch','verifySmtp','messageStatus','sendMail','lastName','imapAccounts','verify','key','total','mailAccounts','refresh','notify','handleImapBox','stringify','connected','info','Mail\x20not\x20accepted\x20from\x20routing\x20%s','emit','./smtp','lastSync','box','./imap','error','prototype','exports','smtp','bind','lodash','email','Smtp','firstName','status','handleImapEnd','active','isNil','end','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','md5','Imap','then'];(function(_0x3c0a61,_0xe8795c){const _0x44678d=function(_0x41a29c){while(--_0x41a29c){_0x3c0a61['push'](_0x3c0a61['shift']());}};_0x44678d(++_0xe8795c);}(a1316_0x4467,0xc6));const a1316_0x41a2=function(_0x3c0a61,_0xe8795c){_0x3c0a61=_0x3c0a61-0x1cc;let _0x44678d=a1316_0x4467[_0x3c0a61];return _0x44678d;};const a1316_0x3a9de0=a1316_0x41a2;'use strict';const _=require(a1316_0x3a9de0(0x1ee)),moment=require('moment'),md5=require(a1316_0x3a9de0(0x1f8)),logger=require(a1316_0x3a9de0(0x1fc))(a1316_0x3a9de0(0x1ef)),{getSocket}=require(a1316_0x3a9de0(0x1ce)),io=getSocket(),EmailImap=require(a1316_0x3a9de0(0x1e8)),EmailSmtp=require(a1316_0x3a9de0(0x1e5)),mailAccount=require('../rpc/mailAccount'),md5Accounts={};function EmailChannel(_0x270361){const _0x33e02d=a1316_0x3a9de0;logger[_0x33e02d(0x1e2)](_0x33e02d(0x1d2)),this[_0x33e02d(0x1dc)]=_0x270361[_0x33e02d(0x1dc)],this[_0x33e02d(0x1d8)]={},this[_0x33e02d(0x1ec)]=new EmailSmtp();}EmailChannel[a1316_0x3a9de0(0x1ea)][a1316_0x3a9de0(0x1e4)]=function(_0x2c45d4){const _0x1fb1fa=a1316_0x3a9de0,_0xcb009f=this[_0x1fb1fa(0x1dc)][_0x2c45d4],_0xe66a36={'id':_0xcb009f['id'],'name':_0xcb009f[_0x1fb1fa(0x1cf)],'key':_0xcb009f[_0x1fb1fa(0x1da)],'active':_0xcb009f[_0x1fb1fa(0x1f4)],'Imap':{'status':_0xcb009f[_0x1fb1fa(0x1f9)][_0x1fb1fa(0x1f2)],'messageStatus':_0xcb009f[_0x1fb1fa(0x1f9)][_0x1fb1fa(0x1d5)],'total':_0xcb009f[_0x1fb1fa(0x1f9)][_0x1fb1fa(0x1db)]}};_[_0x1fb1fa(0x1f5)](md5Accounts[_0x2c45d4])&&(md5Accounts[_0x2c45d4]={});const _0x158fc7=md5(JSON[_0x1fb1fa(0x1e0)](_0xe66a36));md5Accounts[_0x2c45d4][_0x1fb1fa(0x1f8)]!==_0x158fc7&&(md5Accounts[_0x2c45d4][_0x1fb1fa(0x1f8)]=_0x158fc7,io[_0x1fb1fa(0x1e4)](_0x1fb1fa(0x1d0),_0xe66a36));},EmailChannel[a1316_0x3a9de0(0x1ea)][a1316_0x3a9de0(0x1dd)]=function(_0x403792){const _0x408086=a1316_0x3a9de0;for(const _0x1f9969 in _0x403792){if(typeof _0x403792[_0x1f9969]!==_0x408086(0x1cd)){if(_0x403792[_0x1f9969]['Imap']&&_0x403792[_0x1f9969][_0x408086(0x1f4)]){const _0x4d48de=_0x403792[_0x1f9969][_0x408086(0x1f9)];typeof this[_0x408086(0x1d8)][_0x4d48de['id']]===_0x408086(0x1cd)&&(this[_0x408086(0x1d8)][_0x4d48de['id']]=new EmailImap(_0x4d48de,_0x403792[_0x1f9969][_0x408086(0x1ef)]),this[_0x408086(0x1d8)][_0x4d48de['id']]['on'](_0x408086(0x1e7),this['handleImapBox']['bind'](this,_0x1f9969)),this[_0x408086(0x1d8)][_0x4d48de['id']]['on'](_0x408086(0x1ef),this[_0x408086(0x1fb)]['bind'](this,_0x1f9969)),this[_0x408086(0x1d8)][_0x4d48de['id']]['on'](_0x408086(0x1f6),this[_0x408086(0x1f3)][_0x408086(0x1ed)](this,_0x1f9969)),this[_0x408086(0x1d8)][_0x4d48de['id']]['on'](_0x408086(0x1e9),this[_0x408086(0x1cc)][_0x408086(0x1ed)](this,_0x1f9969)));}else _[_0x408086(0x1f5)](this[_0x408086(0x1dc)][_0x1f9969]['Imap'])&&(this['mailAccounts'][_0x1f9969]['Imap']={}),this[_0x408086(0x1dc)][_0x1f9969]['Imap'][_0x408086(0x1f2)]='disabled',this[_0x408086(0x1dc)][_0x1f9969][_0x408086(0x1f9)][_0x408086(0x1d5)]='',this['emit'](_0x1f9969);}}},EmailChannel['prototype'][a1316_0x3a9de0(0x1df)]=function(_0x1b9d19,_0x585d55){const _0x1d0fcf=a1316_0x3a9de0;if(this['mailAccounts'][_0x1b9d19])return this[_0x1d0fcf(0x1dc)][_0x1b9d19][_0x1d0fcf(0x1f9)][_0x1d0fcf(0x1f2)]=_0x1d0fcf(0x1e1),this['mailAccounts'][_0x1b9d19][_0x1d0fcf(0x1f9)]['messageStatus']=_0x585d55[_0x1d0fcf(0x1cf)],_0x585d55[_0x1d0fcf(0x1d1)]&&(this[_0x1d0fcf(0x1dc)][_0x1b9d19]['Imap'][_0x1d0fcf(0x1db)]=_0x585d55[_0x1d0fcf(0x1d1)][_0x1d0fcf(0x1db)]),this[_0x1d0fcf(0x1e4)](_0x1b9d19);},EmailChannel[a1316_0x3a9de0(0x1ea)][a1316_0x3a9de0(0x1fb)]=function(_0x548509,_0x5d21f3){const _0x5ced6a=a1316_0x3a9de0;logger[_0x5ced6a(0x1e2)](_0x5ced6a(0x1f7),_0x5d21f3[_0x5ced6a(0x1f1)],_0x5d21f3[_0x5ced6a(0x1d7)],_0x5d21f3['from'],_0x548509);if(this[_0x5ced6a(0x1dc)][_0x548509])return mailAccount[_0x5ced6a(0x1de)](_0x548509,_0x5d21f3)[_0x5ced6a(0x1fa)](function(_0x351343){const _0x5aa8cf=_0x5ced6a;_0x351343&&logger[_0x5aa8cf(0x1e2)]('Mail\x20accepted\x20from\x20routing');})[_0x5ced6a(0x1d3)](function(_0x1e6c65){const _0xd7dc76=_0x5ced6a;logger[_0xd7dc76(0x1e9)](_0xd7dc76(0x1e3),JSON['stringify'](_0x1e6c65));});},EmailChannel[a1316_0x3a9de0(0x1ea)][a1316_0x3a9de0(0x1f3)]=function(_0x2e2d9f){const _0x5c3b2f=a1316_0x3a9de0;this['mailAccounts'][_0x2e2d9f]&&this[_0x5c3b2f(0x1dc)][_0x2e2d9f][_0x5c3b2f(0x1f9)]&&(this['imapAccounts'][this[_0x5c3b2f(0x1dc)][_0x2e2d9f][_0x5c3b2f(0x1f9)]['id']]&&delete this['imapAccounts'][this[_0x5c3b2f(0x1dc)][_0x2e2d9f][_0x5c3b2f(0x1f9)]['id']],this[_0x5c3b2f(0x1dc)][_0x2e2d9f][_0x5c3b2f(0x1f9)][_0x5c3b2f(0x1e6)]=moment(),this[_0x5c3b2f(0x1e4)](_0x2e2d9f));},EmailChannel[a1316_0x3a9de0(0x1ea)]['handleImapError']=function(_0x208ed5,_0x225ceb){const _0x28f068=a1316_0x3a9de0;if(this[_0x28f068(0x1dc)][_0x208ed5])return this[_0x28f068(0x1dc)][_0x208ed5]['Imap'][_0x28f068(0x1f2)]=_0x28f068(0x1e9),this['mailAccounts'][_0x208ed5]['Imap'][_0x28f068(0x1d5)]=_0x225ceb,this[_0x28f068(0x1e4)](_0x208ed5);},EmailChannel[a1316_0x3a9de0(0x1ea)][a1316_0x3a9de0(0x1d6)]=function(_0x540d4e,_0x4f2671){const _0x387125=a1316_0x3a9de0;return this[_0x387125(0x1ec)]['send'](_0x540d4e,_0x4f2671);},EmailChannel[a1316_0x3a9de0(0x1ea)][a1316_0x3a9de0(0x1d4)]=function(_0x3aa96a){const _0x636d8d=a1316_0x3a9de0,_0x515e07=this;if(this[_0x636d8d(0x1dc)][_0x3aa96a['id']])return _[_0x636d8d(0x1f5)](this[_0x636d8d(0x1dc)][_0x3aa96a['id']][_0x636d8d(0x1f0)])&&(this[_0x636d8d(0x1dc)][_0x3aa96a['id']]['Smtp']={}),this[_0x636d8d(0x1dc)][_0x3aa96a['id']]['Smtp'][_0x636d8d(0x1e6)]=moment(),new Promise(function(_0x2b23cb,_0x2a953c){const _0x2d8a53=_0x636d8d;return _0x515e07[_0x2d8a53(0x1ec)][_0x2d8a53(0x1d9)](_0x3aa96a)[_0x2d8a53(0x1fa)](function(_0x1eb1a9){const _0x10fb24=_0x2d8a53;_0x515e07['mailAccounts'][_0x3aa96a['id']][_0x10fb24(0x1f0)][_0x10fb24(0x1f2)]='verified',_0x515e07[_0x10fb24(0x1dc)][_0x3aa96a['id']][_0x10fb24(0x1f0)]['messageStatus']='',_0x515e07[_0x10fb24(0x1e4)](_0x3aa96a['id']),_0x2b23cb(_0x1eb1a9);})['catch'](function(_0x36e184){const _0x8c4be0=_0x2d8a53;_0x515e07[_0x8c4be0(0x1dc)][_0x3aa96a['id']][_0x8c4be0(0x1f0)][_0x8c4be0(0x1f2)]='error',_0x515e07['mailAccounts'][_0x3aa96a['id']][_0x8c4be0(0x1f0)][_0x8c4be0(0x1d5)]=_0x36e184,_0x515e07[_0x8c4be0(0x1e4)](_0x3aa96a['id']),_0x2a953c(_0x36e184);});});return this[_0x636d8d(0x1ec)]['verify'](_0x3aa96a);},module[a1316_0x3a9de0(0x1eb)]=EmailChannel;
\ No newline at end of file
+const a1320_0x79ba=['../../../config/logger','bind','start\x20email\x20channel','stringify','handleImapEnd','then','mailAccounts','notify','error','handleImapError','total','catch','key','name','md5','send','email','status','verify','../../../rediscache','sendMail','exports','disabled','./imap','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','prototype','messages','Imap','../rpc/mailAccount','active','undefined','verifySmtp','Smtp','from','imapAccounts','info','Mail\x20not\x20accepted\x20from\x20routing\x20%s','moment','emit','./smtp','smtp','handleImapEmail','mailAccount:update','firstName','box','messageStatus','lastName','isNil','handleImapBox','end','Mail\x20accepted\x20from\x20routing'];(function(_0x23873f,_0x4aec82){const _0x79bae9=function(_0x463ab2){while(--_0x463ab2){_0x23873f['push'](_0x23873f['shift']());}};_0x79bae9(++_0x4aec82);}(a1320_0x79ba,0x9b));const a1320_0x463a=function(_0x23873f,_0x4aec82){_0x23873f=_0x23873f-0x18e;let _0x79bae9=a1320_0x79ba[_0x23873f];return _0x79bae9;};const a1320_0x4c189e=a1320_0x463a;'use strict';const _=require('lodash'),moment=require(a1320_0x4c189e(0x1b1)),md5=require(a1320_0x4c189e(0x19a)),logger=require(a1320_0x4c189e(0x1bf))(a1320_0x4c189e(0x19c)),{getSocket}=require(a1320_0x4c189e(0x19f)),io=getSocket(),EmailImap=require(a1320_0x4c189e(0x1a3)),EmailSmtp=require(a1320_0x4c189e(0x1b3)),mailAccount=require(a1320_0x4c189e(0x1a8)),md5Accounts={};function EmailChannel(_0x56e05d){const _0x5e1ba6=a1320_0x4c189e;logger[_0x5e1ba6(0x1af)](_0x5e1ba6(0x18e)),this[_0x5e1ba6(0x192)]=_0x56e05d[_0x5e1ba6(0x192)],this[_0x5e1ba6(0x1ae)]={},this['smtp']=new EmailSmtp();}EmailChannel['prototype'][a1320_0x4c189e(0x1b2)]=function(_0x367a5f){const _0xbb43b=a1320_0x4c189e,_0x270f0a=this['mailAccounts'][_0x367a5f],_0x5f1e38={'id':_0x270f0a['id'],'name':_0x270f0a[_0xbb43b(0x199)],'key':_0x270f0a[_0xbb43b(0x198)],'active':_0x270f0a[_0xbb43b(0x1a9)],'Imap':{'status':_0x270f0a['Imap'][_0xbb43b(0x19d)],'messageStatus':_0x270f0a['Imap'][_0xbb43b(0x1b9)],'total':_0x270f0a[_0xbb43b(0x1a7)][_0xbb43b(0x196)]}};_[_0xbb43b(0x1bb)](md5Accounts[_0x367a5f])&&(md5Accounts[_0x367a5f]={});const _0x368db4=md5(JSON[_0xbb43b(0x18f)](_0x5f1e38));md5Accounts[_0x367a5f][_0xbb43b(0x19a)]!==_0x368db4&&(md5Accounts[_0x367a5f]['md5']=_0x368db4,io[_0xbb43b(0x1b2)](_0xbb43b(0x1b6),_0x5f1e38));},EmailChannel[a1320_0x4c189e(0x1a5)]['refresh']=function(_0x414fa7){const _0x2355ee=a1320_0x4c189e;for(const _0x370945 in _0x414fa7){if(typeof _0x414fa7[_0x370945]!==_0x2355ee(0x1aa)){if(_0x414fa7[_0x370945][_0x2355ee(0x1a7)]&&_0x414fa7[_0x370945]['active']){const _0x57cc30=_0x414fa7[_0x370945][_0x2355ee(0x1a7)];typeof this[_0x2355ee(0x1ae)][_0x57cc30['id']]===_0x2355ee(0x1aa)&&(this['imapAccounts'][_0x57cc30['id']]=new EmailImap(_0x57cc30,_0x414fa7[_0x370945][_0x2355ee(0x19c)]),this['imapAccounts'][_0x57cc30['id']]['on'](_0x2355ee(0x1b8),this[_0x2355ee(0x1bc)]['bind'](this,_0x370945)),this['imapAccounts'][_0x57cc30['id']]['on']('email',this['handleImapEmail'][_0x2355ee(0x1c0)](this,_0x370945)),this[_0x2355ee(0x1ae)][_0x57cc30['id']]['on'](_0x2355ee(0x1bd),this[_0x2355ee(0x190)][_0x2355ee(0x1c0)](this,_0x370945)),this['imapAccounts'][_0x57cc30['id']]['on'](_0x2355ee(0x194),this[_0x2355ee(0x195)]['bind'](this,_0x370945)));}else _['isNil'](this['mailAccounts'][_0x370945][_0x2355ee(0x1a7)])&&(this['mailAccounts'][_0x370945][_0x2355ee(0x1a7)]={}),this[_0x2355ee(0x192)][_0x370945][_0x2355ee(0x1a7)]['status']=_0x2355ee(0x1a2),this[_0x2355ee(0x192)][_0x370945]['Imap'][_0x2355ee(0x1b9)]='',this[_0x2355ee(0x1b2)](_0x370945);}}},EmailChannel[a1320_0x4c189e(0x1a5)][a1320_0x4c189e(0x1bc)]=function(_0x326e61,_0x27bd3a){const _0x383ddf=a1320_0x4c189e;if(this['mailAccounts'][_0x326e61])return this['mailAccounts'][_0x326e61][_0x383ddf(0x1a7)][_0x383ddf(0x19d)]='connected',this[_0x383ddf(0x192)][_0x326e61]['Imap'][_0x383ddf(0x1b9)]=_0x27bd3a['name'],_0x27bd3a[_0x383ddf(0x1a6)]&&(this[_0x383ddf(0x192)][_0x326e61][_0x383ddf(0x1a7)]['total']=_0x27bd3a[_0x383ddf(0x1a6)][_0x383ddf(0x196)]),this[_0x383ddf(0x1b2)](_0x326e61);},EmailChannel['prototype'][a1320_0x4c189e(0x1b5)]=function(_0x18f45d,_0x297c15){const _0x58123a=a1320_0x4c189e;logger[_0x58123a(0x1af)](_0x58123a(0x1a4),_0x297c15[_0x58123a(0x1b7)],_0x297c15[_0x58123a(0x1ba)],_0x297c15[_0x58123a(0x1ad)],_0x18f45d);if(this[_0x58123a(0x192)][_0x18f45d])return mailAccount[_0x58123a(0x193)](_0x18f45d,_0x297c15)[_0x58123a(0x191)](function(_0x138bda){const _0x35bc78=_0x58123a;_0x138bda&&logger['info'](_0x35bc78(0x1be));})['catch'](function(_0x511a5c){const _0x4b1bd4=_0x58123a;logger['error'](_0x4b1bd4(0x1b0),JSON['stringify'](_0x511a5c));});},EmailChannel[a1320_0x4c189e(0x1a5)][a1320_0x4c189e(0x190)]=function(_0x17f8e9){const _0x35679c=a1320_0x4c189e;this[_0x35679c(0x192)][_0x17f8e9]&&this[_0x35679c(0x192)][_0x17f8e9][_0x35679c(0x1a7)]&&(this[_0x35679c(0x1ae)][this[_0x35679c(0x192)][_0x17f8e9][_0x35679c(0x1a7)]['id']]&&delete this['imapAccounts'][this['mailAccounts'][_0x17f8e9][_0x35679c(0x1a7)]['id']],this[_0x35679c(0x192)][_0x17f8e9][_0x35679c(0x1a7)]['lastSync']=moment(),this[_0x35679c(0x1b2)](_0x17f8e9));},EmailChannel[a1320_0x4c189e(0x1a5)][a1320_0x4c189e(0x195)]=function(_0x6dbb7a,_0x29fc37){const _0x3140b1=a1320_0x4c189e;if(this[_0x3140b1(0x192)][_0x6dbb7a])return this[_0x3140b1(0x192)][_0x6dbb7a][_0x3140b1(0x1a7)][_0x3140b1(0x19d)]=_0x3140b1(0x194),this[_0x3140b1(0x192)][_0x6dbb7a][_0x3140b1(0x1a7)]['messageStatus']=_0x29fc37,this[_0x3140b1(0x1b2)](_0x6dbb7a);},EmailChannel[a1320_0x4c189e(0x1a5)][a1320_0x4c189e(0x1a0)]=function(_0x37e2d3,_0x20e2dc){const _0x166dd1=a1320_0x4c189e;return this[_0x166dd1(0x1b4)][_0x166dd1(0x19b)](_0x37e2d3,_0x20e2dc);},EmailChannel[a1320_0x4c189e(0x1a5)][a1320_0x4c189e(0x1ab)]=function(_0xf50f24){const _0x4cbab2=a1320_0x4c189e,_0x5907ad=this;if(this[_0x4cbab2(0x192)][_0xf50f24['id']])return _[_0x4cbab2(0x1bb)](this[_0x4cbab2(0x192)][_0xf50f24['id']][_0x4cbab2(0x1ac)])&&(this['mailAccounts'][_0xf50f24['id']]['Smtp']={}),this[_0x4cbab2(0x192)][_0xf50f24['id']][_0x4cbab2(0x1ac)]['lastSync']=moment(),new Promise(function(_0x3801b9,_0x1a4423){const _0x1e6c51=_0x4cbab2;return _0x5907ad[_0x1e6c51(0x1b4)][_0x1e6c51(0x19e)](_0xf50f24)['then'](function(_0x34c20e){const _0x5b08c7=_0x1e6c51;_0x5907ad[_0x5b08c7(0x192)][_0xf50f24['id']][_0x5b08c7(0x1ac)][_0x5b08c7(0x19d)]='verified',_0x5907ad['mailAccounts'][_0xf50f24['id']][_0x5b08c7(0x1ac)][_0x5b08c7(0x1b9)]='',_0x5907ad['emit'](_0xf50f24['id']),_0x3801b9(_0x34c20e);})[_0x1e6c51(0x197)](function(_0x31c30a){const _0xc218aa=_0x1e6c51;_0x5907ad['mailAccounts'][_0xf50f24['id']][_0xc218aa(0x1ac)]['status']=_0xc218aa(0x194),_0x5907ad[_0xc218aa(0x192)][_0xf50f24['id']][_0xc218aa(0x1ac)][_0xc218aa(0x1b9)]=_0x31c30a,_0x5907ad[_0xc218aa(0x1b2)](_0xf50f24['id']),_0x1a4423(_0x31c30a);});});return this['smtp'][_0x4cbab2(0x19e)](_0xf50f24);},module[a1320_0x4c189e(0x1a1)]=EmailChannel;
\ No newline at end of file