Built motion from commit a9fb64cc6defd8fb3a5cc199221f878e91c0e969. Version 3.0.0...
[motion-next.git] / server / services / email / lib / email.js
index 1c940a7..bb9dcdf 100644 (file)
@@ -1 +1 @@
-const a1151_0x3786=['isNil','lastSync','handleImapBox','messageStatus','messages','stringify','catch','mailAccount:update','../../../config/logger','total','bind','Imap','refresh','md5','handleImapEmail','moment','notify','status','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','emit','lodash','then','sendMail','email','prototype','start\x20email\x20channel','from','exports','Mail\x20accepted\x20from\x20routing','Mail\x20not\x20accepted\x20from\x20routing\x20%s','handleImapError','send','name','end','./smtp','handleImapEnd','smtp','mailAccounts','info','lastName','error','disabled','box','connected','verifySmtp','Smtp','key','../../../rediscache','imapAccounts','verify','undefined'];(function(_0x3136a3,_0x3786ad){const _0x3f0aaa=function(_0x51d49c){while(--_0x51d49c){_0x3136a3['push'](_0x3136a3['shift']());}};_0x3f0aaa(++_0x3786ad);}(a1151_0x3786,0x191));const a1151_0x3f0a=function(_0x3136a3,_0x3786ad){_0x3136a3=_0x3136a3-0x0;let _0x3f0aaa=a1151_0x3786[_0x3136a3];return _0x3f0aaa;};const _0x31675e=a1151_0x3f0a;'use strict';const _=require(_0x31675e('0x1b')),moment=require(_0x31675e('0x16')),md5=require('md5'),logger=require(_0x31675e('0xf'))(_0x31675e('0x1e')),{getSocket}=require(_0x31675e('0x3')),io=getSocket(),EmailImap=require('./imap'),EmailSmtp=require(_0x31675e('0x29')),mailAccount=require('../rpc/mailAccount'),md5Accounts={};function EmailChannel(_0x51d49c){const _0x262b08=_0x31675e;logger[_0x262b08('0x2d')](_0x262b08('0x20')),this['mailAccounts']=_0x51d49c['mailAccounts'],this[_0x262b08('0x4')]={},this[_0x262b08('0x2b')]=new EmailSmtp();}EmailChannel[_0x31675e('0x1f')][_0x31675e('0x1a')]=function(_0x1e6788){const _0xe1de0e=_0x31675e,_0x3ea187=this['mailAccounts'][_0x1e6788],_0x21b1bc={'id':_0x3ea187['id'],'name':_0x3ea187['name'],'key':_0x3ea187[_0xe1de0e('0x2')],'active':_0x3ea187['active'],'Imap':{'status':_0x3ea187[_0xe1de0e('0x12')][_0xe1de0e('0x18')],'messageStatus':_0x3ea187['Imap'][_0xe1de0e('0xa')],'total':_0x3ea187['Imap']['total']}};_[_0xe1de0e('0x7')](md5Accounts[_0x1e6788])&&(md5Accounts[_0x1e6788]={});const _0x5df958=md5(JSON[_0xe1de0e('0xc')](_0x21b1bc));md5Accounts[_0x1e6788][_0xe1de0e('0x14')]!==_0x5df958&&(md5Accounts[_0x1e6788]['md5']=_0x5df958,io['emit'](_0xe1de0e('0xe'),_0x21b1bc));},EmailChannel[_0x31675e('0x1f')][_0x31675e('0x13')]=function(_0x3106ae){const _0x41722e=_0x31675e;for(const _0x38bdeb in _0x3106ae){if(typeof _0x3106ae[_0x38bdeb]!==_0x41722e('0x6')){if(_0x3106ae[_0x38bdeb][_0x41722e('0x12')]&&_0x3106ae[_0x38bdeb]['active']){const _0x4e4614=_0x3106ae[_0x38bdeb]['Imap'];typeof this[_0x41722e('0x4')][_0x4e4614['id']]===_0x41722e('0x6')&&(this['imapAccounts'][_0x4e4614['id']]=new EmailImap(_0x4e4614,_0x3106ae[_0x38bdeb][_0x41722e('0x1e')]),this[_0x41722e('0x4')][_0x4e4614['id']]['on'](_0x41722e('0x31'),this[_0x41722e('0x9')][_0x41722e('0x11')](this,_0x38bdeb)),this[_0x41722e('0x4')][_0x4e4614['id']]['on'](_0x41722e('0x1e'),this[_0x41722e('0x15')]['bind'](this,_0x38bdeb)),this['imapAccounts'][_0x4e4614['id']]['on'](_0x41722e('0x28'),this[_0x41722e('0x2a')][_0x41722e('0x11')](this,_0x38bdeb)),this['imapAccounts'][_0x4e4614['id']]['on'](_0x41722e('0x2f'),this[_0x41722e('0x25')][_0x41722e('0x11')](this,_0x38bdeb)));}else _['isNil'](this[_0x41722e('0x2c')][_0x38bdeb][_0x41722e('0x12')])&&(this['mailAccounts'][_0x38bdeb][_0x41722e('0x12')]={}),this['mailAccounts'][_0x38bdeb][_0x41722e('0x12')][_0x41722e('0x18')]=_0x41722e('0x30'),this[_0x41722e('0x2c')][_0x38bdeb][_0x41722e('0x12')]['messageStatus']='',this[_0x41722e('0x1a')](_0x38bdeb);}}},EmailChannel['prototype'][_0x31675e('0x9')]=function(_0x536b9a,_0x1e3b3c){const _0x2b2475=_0x31675e;if(this[_0x2b2475('0x2c')][_0x536b9a])return this['mailAccounts'][_0x536b9a][_0x2b2475('0x12')]['status']=_0x2b2475('0x32'),this[_0x2b2475('0x2c')][_0x536b9a]['Imap'][_0x2b2475('0xa')]=_0x1e3b3c[_0x2b2475('0x27')],_0x1e3b3c[_0x2b2475('0xb')]&&(this[_0x2b2475('0x2c')][_0x536b9a][_0x2b2475('0x12')][_0x2b2475('0x10')]=_0x1e3b3c['messages'][_0x2b2475('0x10')]),this[_0x2b2475('0x1a')](_0x536b9a);},EmailChannel[_0x31675e('0x1f')]['handleImapEmail']=function(_0x3fc60f,_0x7aa8a3){const _0x4e24a7=_0x31675e;logger['info'](_0x4e24a7('0x19'),_0x7aa8a3['firstName'],_0x7aa8a3[_0x4e24a7('0x2e')],_0x7aa8a3[_0x4e24a7('0x21')],_0x3fc60f);if(this[_0x4e24a7('0x2c')][_0x3fc60f])return mailAccount[_0x4e24a7('0x17')](_0x3fc60f,_0x7aa8a3)[_0x4e24a7('0x1c')](function(_0x2f4f87){const _0x5b50b7=_0x4e24a7;_0x2f4f87&&logger[_0x5b50b7('0x2d')](_0x5b50b7('0x23'));})[_0x4e24a7('0xd')](function(_0xb29c3c){const _0x38baf0=_0x4e24a7;logger[_0x38baf0('0x2f')](_0x38baf0('0x24'),JSON[_0x38baf0('0xc')](_0xb29c3c));});},EmailChannel[_0x31675e('0x1f')][_0x31675e('0x2a')]=function(_0xc846b5){const _0xea6aae=_0x31675e;this[_0xea6aae('0x2c')][_0xc846b5]&&this['mailAccounts'][_0xc846b5][_0xea6aae('0x12')]&&(this[_0xea6aae('0x4')][this['mailAccounts'][_0xc846b5][_0xea6aae('0x12')]['id']]&&delete this['imapAccounts'][this['mailAccounts'][_0xc846b5][_0xea6aae('0x12')]['id']],this['mailAccounts'][_0xc846b5][_0xea6aae('0x12')]['lastSync']=moment(),this[_0xea6aae('0x1a')](_0xc846b5));},EmailChannel[_0x31675e('0x1f')][_0x31675e('0x25')]=function(_0xfceea,_0x25e97d){const _0x28e7e4=_0x31675e;if(this['mailAccounts'][_0xfceea])return this[_0x28e7e4('0x2c')][_0xfceea][_0x28e7e4('0x12')][_0x28e7e4('0x18')]=_0x28e7e4('0x2f'),this[_0x28e7e4('0x2c')][_0xfceea]['Imap'][_0x28e7e4('0xa')]=_0x25e97d,this['emit'](_0xfceea);},EmailChannel[_0x31675e('0x1f')][_0x31675e('0x1d')]=function(_0x3aa52b,_0x5e959e){const _0x905244=_0x31675e;return this['smtp'][_0x905244('0x26')](_0x3aa52b,_0x5e959e);},EmailChannel[_0x31675e('0x1f')][_0x31675e('0x0')]=function(_0x20ce15){const _0x41e985=_0x31675e,_0x40e6e8=this;if(this[_0x41e985('0x2c')][_0x20ce15['id']])return _['isNil'](this[_0x41e985('0x2c')][_0x20ce15['id']][_0x41e985('0x1')])&&(this[_0x41e985('0x2c')][_0x20ce15['id']][_0x41e985('0x1')]={}),this[_0x41e985('0x2c')][_0x20ce15['id']][_0x41e985('0x1')][_0x41e985('0x8')]=moment(),new Promise(function(_0x1919ae,_0x35a50a){const _0x4539e0=_0x41e985;return _0x40e6e8['smtp'][_0x4539e0('0x5')](_0x20ce15)['then'](function(_0x409ebe){const _0x4d0a64=_0x4539e0;_0x40e6e8[_0x4d0a64('0x2c')][_0x20ce15['id']][_0x4d0a64('0x1')]['status']='verified',_0x40e6e8[_0x4d0a64('0x2c')][_0x20ce15['id']]['Smtp'][_0x4d0a64('0xa')]='',_0x40e6e8[_0x4d0a64('0x1a')](_0x20ce15['id']),_0x1919ae(_0x409ebe);})[_0x4539e0('0xd')](function(_0x55ba34){const _0x2ffdcd=_0x4539e0;_0x40e6e8[_0x2ffdcd('0x2c')][_0x20ce15['id']]['Smtp']['status']=_0x2ffdcd('0x2f'),_0x40e6e8[_0x2ffdcd('0x2c')][_0x20ce15['id']]['Smtp'][_0x2ffdcd('0xa')]=_0x55ba34,_0x40e6e8[_0x2ffdcd('0x1a')](_0x20ce15['id']),_0x35a50a(_0x55ba34);});});return this[_0x41e985('0x2b')][_0x41e985('0x5')](_0x20ce15);},module[_0x31675e('0x22')]=EmailChannel;
\ No newline at end of file
+const a1151_0x56ff=['New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','handleImapEmail','from','Smtp','catch','verify','Imap','firstName','box','md5','error','moment','messages','emit','../../../rediscache','total','prototype','handleImapBox','email','bind','smtp','../rpc/mailAccount','handleImapEnd','mailAccount:update','exports','then','send','start\x20email\x20channel','stringify','disabled','connected','isNil','lastSync','Mail\x20not\x20accepted\x20from\x20routing\x20%s','handleImapError','undefined','info','mailAccounts','imapAccounts','Mail\x20accepted\x20from\x20routing','lodash','active','status','./imap','../../../config/logger','messageStatus','key','name','lastName','./smtp','sendMail'];(function(_0x37cdc7,_0x56ff30){const _0x48e968=function(_0x550a2f){while(--_0x550a2f){_0x37cdc7['push'](_0x37cdc7['shift']());}};_0x48e968(++_0x56ff30);}(a1151_0x56ff,0x17d));const a1151_0x48e9=function(_0x37cdc7,_0x56ff30){_0x37cdc7=_0x37cdc7-0x0;let _0x48e968=a1151_0x56ff[_0x37cdc7];return _0x48e968;};const _0x5c25fa=a1151_0x48e9;'use strict';const _=require(_0x5c25fa('0x10')),moment=require(_0x5c25fa('0x26')),md5=require('md5'),logger=require(_0x5c25fa('0x14'))(_0x5c25fa('0x2d')),{getSocket}=require(_0x5c25fa('0x29')),io=getSocket(),EmailImap=require(_0x5c25fa('0x13')),EmailSmtp=require(_0x5c25fa('0x19')),mailAccount=require(_0x5c25fa('0x30')),md5Accounts={};function EmailChannel(_0x550a2f){const _0x10e484=_0x5c25fa;logger[_0x10e484('0xc')](_0x10e484('0x3')),this[_0x10e484('0xd')]=_0x550a2f[_0x10e484('0xd')],this[_0x10e484('0xe')]={},this[_0x10e484('0x2f')]=new EmailSmtp();}EmailChannel[_0x5c25fa('0x2b')][_0x5c25fa('0x28')]=function(_0x32fce4){const _0x14c6b6=_0x5c25fa,_0x31c976=this[_0x14c6b6('0xd')][_0x32fce4],_0x42f136={'id':_0x31c976['id'],'name':_0x31c976['name'],'key':_0x31c976[_0x14c6b6('0x16')],'active':_0x31c976[_0x14c6b6('0x11')],'Imap':{'status':_0x31c976[_0x14c6b6('0x21')]['status'],'messageStatus':_0x31c976[_0x14c6b6('0x21')]['messageStatus'],'total':_0x31c976[_0x14c6b6('0x21')][_0x14c6b6('0x2a')]}};_['isNil'](md5Accounts[_0x32fce4])&&(md5Accounts[_0x32fce4]={});const _0x5d39e8=md5(JSON['stringify'](_0x42f136));md5Accounts[_0x32fce4][_0x14c6b6('0x24')]!==_0x5d39e8&&(md5Accounts[_0x32fce4][_0x14c6b6('0x24')]=_0x5d39e8,io['emit'](_0x14c6b6('0x32'),_0x42f136));},EmailChannel['prototype']['refresh']=function(_0x4e669f){const _0x5e181=_0x5c25fa;for(const _0x46f876 in _0x4e669f){if(typeof _0x4e669f[_0x46f876]!==_0x5e181('0xb')){if(_0x4e669f[_0x46f876]['Imap']&&_0x4e669f[_0x46f876][_0x5e181('0x11')]){const _0x1c8cee=_0x4e669f[_0x46f876][_0x5e181('0x21')];typeof this['imapAccounts'][_0x1c8cee['id']]===_0x5e181('0xb')&&(this[_0x5e181('0xe')][_0x1c8cee['id']]=new EmailImap(_0x1c8cee,_0x4e669f[_0x46f876][_0x5e181('0x2d')]),this[_0x5e181('0xe')][_0x1c8cee['id']]['on'](_0x5e181('0x23'),this[_0x5e181('0x2c')][_0x5e181('0x2e')](this,_0x46f876)),this[_0x5e181('0xe')][_0x1c8cee['id']]['on'](_0x5e181('0x2d'),this[_0x5e181('0x1c')][_0x5e181('0x2e')](this,_0x46f876)),this[_0x5e181('0xe')][_0x1c8cee['id']]['on']('end',this['handleImapEnd'][_0x5e181('0x2e')](this,_0x46f876)),this['imapAccounts'][_0x1c8cee['id']]['on'](_0x5e181('0x25'),this[_0x5e181('0xa')]['bind'](this,_0x46f876)));}else _[_0x5e181('0x7')](this[_0x5e181('0xd')][_0x46f876][_0x5e181('0x21')])&&(this[_0x5e181('0xd')][_0x46f876][_0x5e181('0x21')]={}),this['mailAccounts'][_0x46f876][_0x5e181('0x21')][_0x5e181('0x12')]=_0x5e181('0x5'),this[_0x5e181('0xd')][_0x46f876]['Imap'][_0x5e181('0x15')]='',this[_0x5e181('0x28')](_0x46f876);}}},EmailChannel[_0x5c25fa('0x2b')][_0x5c25fa('0x2c')]=function(_0x5e742b,_0x172715){const _0x4b4129=_0x5c25fa;if(this['mailAccounts'][_0x5e742b])return this[_0x4b4129('0xd')][_0x5e742b][_0x4b4129('0x21')][_0x4b4129('0x12')]=_0x4b4129('0x6'),this[_0x4b4129('0xd')][_0x5e742b][_0x4b4129('0x21')]['messageStatus']=_0x172715[_0x4b4129('0x17')],_0x172715[_0x4b4129('0x27')]&&(this[_0x4b4129('0xd')][_0x5e742b]['Imap'][_0x4b4129('0x2a')]=_0x172715[_0x4b4129('0x27')]['total']),this['emit'](_0x5e742b);},EmailChannel[_0x5c25fa('0x2b')]['handleImapEmail']=function(_0x4b9d4b,_0x27abe6){const _0x2a517d=_0x5c25fa;logger[_0x2a517d('0xc')](_0x2a517d('0x1b'),_0x27abe6[_0x2a517d('0x22')],_0x27abe6[_0x2a517d('0x18')],_0x27abe6[_0x2a517d('0x1d')],_0x4b9d4b);if(this[_0x2a517d('0xd')][_0x4b9d4b])return mailAccount['notify'](_0x4b9d4b,_0x27abe6)[_0x2a517d('0x1')](function(_0x75c9a9){const _0x471040=_0x2a517d;_0x75c9a9&&logger['info'](_0x471040('0xf'));})[_0x2a517d('0x1f')](function(_0x3bd2a3){const _0x48e8fd=_0x2a517d;logger[_0x48e8fd('0x25')](_0x48e8fd('0x9'),JSON[_0x48e8fd('0x4')](_0x3bd2a3));});},EmailChannel[_0x5c25fa('0x2b')][_0x5c25fa('0x31')]=function(_0x3d00bf){const _0x58e6d4=_0x5c25fa;this['mailAccounts'][_0x3d00bf]&&this[_0x58e6d4('0xd')][_0x3d00bf]['Imap']&&(this[_0x58e6d4('0xe')][this[_0x58e6d4('0xd')][_0x3d00bf]['Imap']['id']]&&delete this['imapAccounts'][this[_0x58e6d4('0xd')][_0x3d00bf][_0x58e6d4('0x21')]['id']],this[_0x58e6d4('0xd')][_0x3d00bf][_0x58e6d4('0x21')][_0x58e6d4('0x8')]=moment(),this[_0x58e6d4('0x28')](_0x3d00bf));},EmailChannel[_0x5c25fa('0x2b')]['handleImapError']=function(_0x143df0,_0x47b250){const _0x3b8330=_0x5c25fa;if(this[_0x3b8330('0xd')][_0x143df0])return this[_0x3b8330('0xd')][_0x143df0][_0x3b8330('0x21')]['status']=_0x3b8330('0x25'),this[_0x3b8330('0xd')][_0x143df0][_0x3b8330('0x21')][_0x3b8330('0x15')]=_0x47b250,this['emit'](_0x143df0);},EmailChannel['prototype'][_0x5c25fa('0x1a')]=function(_0x4e9641,_0x3a9f6f){const _0x31c9f8=_0x5c25fa;return this[_0x31c9f8('0x2f')][_0x31c9f8('0x2')](_0x4e9641,_0x3a9f6f);},EmailChannel[_0x5c25fa('0x2b')]['verifySmtp']=function(_0x53b682){const _0x3649d0=_0x5c25fa,_0x4d5a14=this;if(this['mailAccounts'][_0x53b682['id']])return _[_0x3649d0('0x7')](this['mailAccounts'][_0x53b682['id']]['Smtp'])&&(this[_0x3649d0('0xd')][_0x53b682['id']][_0x3649d0('0x1e')]={}),this[_0x3649d0('0xd')][_0x53b682['id']]['Smtp']['lastSync']=moment(),new Promise(function(_0x4ee737,_0x540735){const _0x12d43c=_0x3649d0;return _0x4d5a14[_0x12d43c('0x2f')][_0x12d43c('0x20')](_0x53b682)[_0x12d43c('0x1')](function(_0x395229){const _0x115a24=_0x12d43c;_0x4d5a14[_0x115a24('0xd')][_0x53b682['id']][_0x115a24('0x1e')][_0x115a24('0x12')]='verified',_0x4d5a14[_0x115a24('0xd')][_0x53b682['id']][_0x115a24('0x1e')][_0x115a24('0x15')]='',_0x4d5a14['emit'](_0x53b682['id']),_0x4ee737(_0x395229);})[_0x12d43c('0x1f')](function(_0x52279a){const _0x23639b=_0x12d43c;_0x4d5a14[_0x23639b('0xd')][_0x53b682['id']]['Smtp']['status']=_0x23639b('0x25'),_0x4d5a14[_0x23639b('0xd')][_0x53b682['id']][_0x23639b('0x1e')][_0x23639b('0x15')]=_0x52279a,_0x4d5a14[_0x23639b('0x28')](_0x53b682['id']),_0x540735(_0x52279a);});});return this[_0x3649d0('0x2f')][_0x3649d0('0x20')](_0x53b682);},module[_0x5c25fa('0x0')]=EmailChannel;
\ No newline at end of file