Built motion from commit (unavailable).|2.4.13
[motion2.git] / server / services / email / lib / email.js
index 712b6ef..cf6b9da 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x76a9=['handleImapError','disabled','connected','messageStatus','name','messages','handleImapEmail','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','firstName','lastName','from','then','Mail\x20accepted\x20from\x20routing','Mail\x20not\x20accepted\x20from\x20routing\x20%s','lastSync','sendMail','verifySmtp','Smtp','verify','verified','exports','lodash','moment','bluebird','md5','ioredis','../../../config/environment','../../../config/logger','redis','defaults','localhost','socket.io-emitter','./imap','./smtp','info','mailAccounts','imapAccounts','smtp','prototype','emit','active','Imap','status','total','isNil','stringify','mailAccount:update','refresh','hasOwnProperty','email','handleImapBox','bind','handleImapEnd','error'];(function(_0x1dc38f,_0x1ca66b){var _0x580ea4=function(_0x3c1652){while(--_0x3c1652){_0x1dc38f['push'](_0x1dc38f['shift']());}};_0x580ea4(++_0x1ca66b);}(_0x76a9,0x123));var _0x976a=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x76a9[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x976a('0x0'));var moment=require(_0x976a('0x1'));var BPromise=require(_0x976a('0x2'));var md5=require(_0x976a('0x3'));var Redis=require(_0x976a('0x4'));var config=require(_0x976a('0x5'));var logger=require(_0x976a('0x6'))('email');config[_0x976a('0x7')]=_[_0x976a('0x8')](config[_0x976a('0x7')],{'host':_0x976a('0x9'),'port':0x18eb});var io=require(_0x976a('0xa'))(new Redis(config[_0x976a('0x7')]));var EmailImap=require(_0x976a('0xb'));var EmailSmtp=require(_0x976a('0xc'));var mailAccount=require('../rpc/mailAccount');var md5Accounts={};function EmailChannel(_0x1cf20c){logger[_0x976a('0xd')]('start\x20email\x20channel');this['mailAccounts']=_0x1cf20c[_0x976a('0xe')];this[_0x976a('0xf')]={};this[_0x976a('0x10')]=new EmailSmtp();}EmailChannel[_0x976a('0x11')][_0x976a('0x12')]=function(_0x452849){var _0x3fdb1c=this['mailAccounts'][_0x452849];var _0xe34ddd={'id':_0x3fdb1c['id'],'name':_0x3fdb1c['name'],'key':_0x3fdb1c['key'],'active':_0x3fdb1c[_0x976a('0x13')],'Imap':{'status':_0x3fdb1c[_0x976a('0x14')][_0x976a('0x15')],'messageStatus':_0x3fdb1c['Imap']['messageStatus'],'total':_0x3fdb1c[_0x976a('0x14')][_0x976a('0x16')]}};if(_[_0x976a('0x17')](md5Accounts[_0x452849])){md5Accounts[_0x452849]={};}var _0x50cec6=md5(JSON[_0x976a('0x18')](_0xe34ddd));if(md5Accounts[_0x452849][_0x976a('0x3')]!==_0x50cec6){md5Accounts[_0x452849][_0x976a('0x3')]=_0x50cec6;io[_0x976a('0x12')](_0x976a('0x19'),_0xe34ddd);}};EmailChannel[_0x976a('0x11')][_0x976a('0x1a')]=function(_0xd6025d){for(var _0x4e94c6 in _0xd6025d){if(_0xd6025d[_0x976a('0x1b')](_0x4e94c6)){if(_0xd6025d[_0x4e94c6][_0x976a('0x14')]&&_0xd6025d[_0x4e94c6][_0x976a('0x13')]){var _0x5c23a9=_0xd6025d[_0x4e94c6]['Imap'];if(!this['imapAccounts'][_0x976a('0x1b')](_0x5c23a9['id'])){this['imapAccounts'][_0x5c23a9['id']]=new EmailImap(_0x5c23a9,_0xd6025d[_0x4e94c6][_0x976a('0x1c')]);this[_0x976a('0xf')][_0x5c23a9['id']]['on']('box',this[_0x976a('0x1d')][_0x976a('0x1e')](this,_0x4e94c6));this[_0x976a('0xf')][_0x5c23a9['id']]['on'](_0x976a('0x1c'),this['handleImapEmail']['bind'](this,_0x4e94c6));this[_0x976a('0xf')][_0x5c23a9['id']]['on']('end',this[_0x976a('0x1f')]['bind'](this,_0x4e94c6));this[_0x976a('0xf')][_0x5c23a9['id']]['on'](_0x976a('0x20'),this[_0x976a('0x21')][_0x976a('0x1e')](this,_0x4e94c6));}}else{if(_['isNil'](this[_0x976a('0xe')][_0x4e94c6][_0x976a('0x14')])){this[_0x976a('0xe')][_0x4e94c6]['Imap']={};}this[_0x976a('0xe')][_0x4e94c6][_0x976a('0x14')][_0x976a('0x15')]=_0x976a('0x22');this[_0x976a('0xe')][_0x4e94c6]['Imap']['messageStatus']='';this[_0x976a('0x12')](_0x4e94c6);}}}};EmailChannel[_0x976a('0x11')][_0x976a('0x1d')]=function(_0x50656f,_0x57afa8){if(this[_0x976a('0xe')][_0x50656f]){this[_0x976a('0xe')][_0x50656f]['Imap']['status']=_0x976a('0x23');this[_0x976a('0xe')][_0x50656f]['Imap'][_0x976a('0x24')]=_0x57afa8[_0x976a('0x25')];if(_0x57afa8[_0x976a('0x26')]){this['mailAccounts'][_0x50656f][_0x976a('0x14')]['total']=_0x57afa8[_0x976a('0x26')][_0x976a('0x16')];}return this[_0x976a('0x12')](_0x50656f);}};EmailChannel['prototype'][_0x976a('0x27')]=function(_0x509c24,_0x14a988){logger[_0x976a('0xd')](_0x976a('0x28'),_0x14a988[_0x976a('0x29')],_0x14a988[_0x976a('0x2a')],_0x14a988[_0x976a('0x2b')],_0x509c24);if(this[_0x976a('0xe')][_0x509c24]){return mailAccount['notify'](_0x509c24,_0x14a988)[_0x976a('0x2c')](function(_0x3c2e79){if(_0x3c2e79){logger[_0x976a('0xd')](_0x976a('0x2d'));}})['catch'](function(_0x33c7b9){logger[_0x976a('0x20')](_0x976a('0x2e'),JSON[_0x976a('0x18')](_0x33c7b9));});}};EmailChannel[_0x976a('0x11')][_0x976a('0x1f')]=function(_0x2557e9){if(this[_0x976a('0xe')][_0x2557e9]&&this['mailAccounts'][_0x2557e9]['Imap']){if(this['imapAccounts'][this[_0x976a('0xe')][_0x2557e9]['Imap']['id']]){delete this[_0x976a('0xf')][this[_0x976a('0xe')][_0x2557e9]['Imap']['id']];}this['mailAccounts'][_0x2557e9][_0x976a('0x14')][_0x976a('0x2f')]=moment();this[_0x976a('0x12')](_0x2557e9);}};EmailChannel[_0x976a('0x11')]['handleImapError']=function(_0x17b429,_0x32095e){if(this[_0x976a('0xe')][_0x17b429]){this[_0x976a('0xe')][_0x17b429][_0x976a('0x14')][_0x976a('0x15')]='error';this[_0x976a('0xe')][_0x17b429][_0x976a('0x14')]['messageStatus']=_0x32095e;return this[_0x976a('0x12')](_0x17b429);}};EmailChannel[_0x976a('0x11')][_0x976a('0x30')]=function(_0x5b2878,_0x1c7921){return this[_0x976a('0x10')]['send'](_0x5b2878,_0x1c7921);};EmailChannel['prototype'][_0x976a('0x31')]=function(_0x5d438){var _0x38a919=this;if(this[_0x976a('0xe')][_0x5d438['id']]){if(_[_0x976a('0x17')](this['mailAccounts'][_0x5d438['id']][_0x976a('0x32')])){this[_0x976a('0xe')][_0x5d438['id']]['Smtp']={};}this[_0x976a('0xe')][_0x5d438['id']][_0x976a('0x32')][_0x976a('0x2f')]=moment();return new BPromise(function(_0x40238a,_0x2e95bc){return _0x38a919[_0x976a('0x10')][_0x976a('0x33')](_0x5d438)[_0x976a('0x2c')](function(_0x508baf){_0x38a919[_0x976a('0xe')][_0x5d438['id']][_0x976a('0x32')][_0x976a('0x15')]=_0x976a('0x34');_0x38a919['mailAccounts'][_0x5d438['id']][_0x976a('0x32')][_0x976a('0x24')]='';_0x38a919['emit'](_0x5d438['id']);_0x40238a(_0x508baf);})['catch'](function(_0x2ff9d4){_0x38a919[_0x976a('0xe')][_0x5d438['id']]['Smtp'][_0x976a('0x15')]=_0x976a('0x20');_0x38a919[_0x976a('0xe')][_0x5d438['id']][_0x976a('0x32')]['messageStatus']=_0x2ff9d4;_0x38a919[_0x976a('0x12')](_0x5d438['id']);_0x2e95bc(_0x2ff9d4);});});}return this[_0x976a('0x10')][_0x976a('0x33')](_0x5d438);};module[_0x976a('0x35')]=EmailChannel;
\ No newline at end of file
+var _0xcd85=['messages','firstName','from','notify','then','catch','Mail\x20not\x20accepted\x20from\x20routing\x20%s','lastSync','sendMail','send','Smtp','verify','exports','lodash','moment','bluebird','md5','ioredis','../../../config/logger','redis','defaults','socket.io-emitter','./imap','./smtp','../rpc/mailAccount','info','start\x20email\x20channel','imapAccounts','smtp','emit','mailAccounts','name','active','Imap','status','total','stringify','mailAccount:update','prototype','hasOwnProperty','email','box','handleImapEmail','bind','end','handleImapEnd','error','handleImapError','isNil','disabled','handleImapBox','connected','messageStatus'];(function(_0x34d7cc,_0x2b7d14){var _0x24f692=function(_0x2d3300){while(--_0x2d3300){_0x34d7cc['push'](_0x34d7cc['shift']());}};_0x24f692(++_0x2b7d14);}(_0xcd85,0xac));var _0x5cd8=function(_0x29a707,_0x342505){_0x29a707=_0x29a707-0x0;var _0x229e83=_0xcd85[_0x29a707];return _0x229e83;};'use strict';var _=require(_0x5cd8('0x0'));var moment=require(_0x5cd8('0x1'));var BPromise=require(_0x5cd8('0x2'));var md5=require(_0x5cd8('0x3'));var Redis=require(_0x5cd8('0x4'));var config=require('../../../config/environment');var logger=require(_0x5cd8('0x5'))('email');config[_0x5cd8('0x6')]=_[_0x5cd8('0x7')](config[_0x5cd8('0x6')],{'host':'localhost','port':0x18eb});var io=require(_0x5cd8('0x8'))(new Redis(config[_0x5cd8('0x6')]));var EmailImap=require(_0x5cd8('0x9'));var EmailSmtp=require(_0x5cd8('0xa'));var mailAccount=require(_0x5cd8('0xb'));var md5Accounts={};function EmailChannel(_0x253545){logger[_0x5cd8('0xc')](_0x5cd8('0xd'));this['mailAccounts']=_0x253545['mailAccounts'];this[_0x5cd8('0xe')]={};this[_0x5cd8('0xf')]=new EmailSmtp();}EmailChannel['prototype'][_0x5cd8('0x10')]=function(_0x3e24c8){var _0x427db5=this[_0x5cd8('0x11')][_0x3e24c8];var _0x39d082={'id':_0x427db5['id'],'name':_0x427db5[_0x5cd8('0x12')],'key':_0x427db5['key'],'active':_0x427db5[_0x5cd8('0x13')],'Imap':{'status':_0x427db5[_0x5cd8('0x14')][_0x5cd8('0x15')],'messageStatus':_0x427db5['Imap']['messageStatus'],'total':_0x427db5['Imap'][_0x5cd8('0x16')]}};if(_['isNil'](md5Accounts[_0x3e24c8])){md5Accounts[_0x3e24c8]={};}var _0x2d48ab=md5(JSON[_0x5cd8('0x17')](_0x39d082));if(md5Accounts[_0x3e24c8]['md5']!==_0x2d48ab){md5Accounts[_0x3e24c8][_0x5cd8('0x3')]=_0x2d48ab;io[_0x5cd8('0x10')](_0x5cd8('0x18'),_0x39d082);}};EmailChannel[_0x5cd8('0x19')]['refresh']=function(_0x4f7f66){for(var _0x42141a in _0x4f7f66){if(_0x4f7f66[_0x5cd8('0x1a')](_0x42141a)){if(_0x4f7f66[_0x42141a]['Imap']&&_0x4f7f66[_0x42141a][_0x5cd8('0x13')]){var _0xd7ef99=_0x4f7f66[_0x42141a]['Imap'];if(!this[_0x5cd8('0xe')]['hasOwnProperty'](_0xd7ef99['id'])){this[_0x5cd8('0xe')][_0xd7ef99['id']]=new EmailImap(_0xd7ef99,_0x4f7f66[_0x42141a][_0x5cd8('0x1b')]);this['imapAccounts'][_0xd7ef99['id']]['on'](_0x5cd8('0x1c'),this['handleImapBox']['bind'](this,_0x42141a));this[_0x5cd8('0xe')][_0xd7ef99['id']]['on'](_0x5cd8('0x1b'),this[_0x5cd8('0x1d')][_0x5cd8('0x1e')](this,_0x42141a));this[_0x5cd8('0xe')][_0xd7ef99['id']]['on'](_0x5cd8('0x1f'),this[_0x5cd8('0x20')][_0x5cd8('0x1e')](this,_0x42141a));this[_0x5cd8('0xe')][_0xd7ef99['id']]['on'](_0x5cd8('0x21'),this[_0x5cd8('0x22')]['bind'](this,_0x42141a));}}else{if(_[_0x5cd8('0x23')](this['mailAccounts'][_0x42141a]['Imap'])){this[_0x5cd8('0x11')][_0x42141a][_0x5cd8('0x14')]={};}this[_0x5cd8('0x11')][_0x42141a][_0x5cd8('0x14')][_0x5cd8('0x15')]=_0x5cd8('0x24');this[_0x5cd8('0x11')][_0x42141a][_0x5cd8('0x14')]['messageStatus']='';this['emit'](_0x42141a);}}}};EmailChannel['prototype'][_0x5cd8('0x25')]=function(_0x2e191a,_0x15dcea){if(this['mailAccounts'][_0x2e191a]){this[_0x5cd8('0x11')][_0x2e191a][_0x5cd8('0x14')][_0x5cd8('0x15')]=_0x5cd8('0x26');this[_0x5cd8('0x11')][_0x2e191a][_0x5cd8('0x14')][_0x5cd8('0x27')]=_0x15dcea[_0x5cd8('0x12')];if(_0x15dcea[_0x5cd8('0x28')]){this[_0x5cd8('0x11')][_0x2e191a][_0x5cd8('0x14')][_0x5cd8('0x16')]=_0x15dcea[_0x5cd8('0x28')][_0x5cd8('0x16')];}return this[_0x5cd8('0x10')](_0x2e191a);}};EmailChannel[_0x5cd8('0x19')][_0x5cd8('0x1d')]=function(_0x1b832a,_0x34ee72){logger[_0x5cd8('0xc')]('New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s',_0x34ee72[_0x5cd8('0x29')],_0x34ee72['lastName'],_0x34ee72[_0x5cd8('0x2a')],_0x1b832a);if(this[_0x5cd8('0x11')][_0x1b832a]){return mailAccount[_0x5cd8('0x2b')](_0x1b832a,_0x34ee72)[_0x5cd8('0x2c')](function(_0x354f3a){if(_0x354f3a){logger['info']('Mail\x20accepted\x20from\x20routing');}})[_0x5cd8('0x2d')](function(_0x33a394){logger[_0x5cd8('0x21')](_0x5cd8('0x2e'),JSON['stringify'](_0x33a394));});}};EmailChannel['prototype'][_0x5cd8('0x20')]=function(_0x26f943){if(this[_0x5cd8('0x11')][_0x26f943]&&this[_0x5cd8('0x11')][_0x26f943][_0x5cd8('0x14')]){if(this[_0x5cd8('0xe')][this[_0x5cd8('0x11')][_0x26f943][_0x5cd8('0x14')]['id']]){delete this[_0x5cd8('0xe')][this[_0x5cd8('0x11')][_0x26f943][_0x5cd8('0x14')]['id']];}this[_0x5cd8('0x11')][_0x26f943][_0x5cd8('0x14')][_0x5cd8('0x2f')]=moment();this[_0x5cd8('0x10')](_0x26f943);}};EmailChannel[_0x5cd8('0x19')][_0x5cd8('0x22')]=function(_0x259d87,_0x4b23a1){if(this[_0x5cd8('0x11')][_0x259d87]){this[_0x5cd8('0x11')][_0x259d87][_0x5cd8('0x14')][_0x5cd8('0x15')]=_0x5cd8('0x21');this[_0x5cd8('0x11')][_0x259d87][_0x5cd8('0x14')][_0x5cd8('0x27')]=_0x4b23a1;return this['emit'](_0x259d87);}};EmailChannel[_0x5cd8('0x19')][_0x5cd8('0x30')]=function(_0x304429,_0xa4a2f1){return this['smtp'][_0x5cd8('0x31')](_0x304429,_0xa4a2f1);};EmailChannel[_0x5cd8('0x19')]['verifySmtp']=function(_0x24c42c){var _0x330446=this;if(this[_0x5cd8('0x11')][_0x24c42c['id']]){if(_[_0x5cd8('0x23')](this[_0x5cd8('0x11')][_0x24c42c['id']][_0x5cd8('0x32')])){this[_0x5cd8('0x11')][_0x24c42c['id']][_0x5cd8('0x32')]={};}this[_0x5cd8('0x11')][_0x24c42c['id']][_0x5cd8('0x32')][_0x5cd8('0x2f')]=moment();return new BPromise(function(_0x14f7dc,_0xfd2cf8){return _0x330446['smtp']['verify'](_0x24c42c)[_0x5cd8('0x2c')](function(_0x3c19c6){_0x330446[_0x5cd8('0x11')][_0x24c42c['id']][_0x5cd8('0x32')]['status']='verified';_0x330446['mailAccounts'][_0x24c42c['id']][_0x5cd8('0x32')]['messageStatus']='';_0x330446[_0x5cd8('0x10')](_0x24c42c['id']);_0x14f7dc(_0x3c19c6);})[_0x5cd8('0x2d')](function(_0x22eaeb){_0x330446[_0x5cd8('0x11')][_0x24c42c['id']]['Smtp']['status']=_0x5cd8('0x21');_0x330446[_0x5cd8('0x11')][_0x24c42c['id']]['Smtp'][_0x5cd8('0x27')]=_0x22eaeb;_0x330446[_0x5cd8('0x10')](_0x24c42c['id']);_0xfd2cf8(_0x22eaeb);});});}return this[_0x5cd8('0xf')][_0x5cd8('0x33')](_0x24c42c);};module[_0x5cd8('0x34')]=EmailChannel;
\ No newline at end of file