Built motion from commit (unavailable).|2.0.75
[motion2.git] / server / services / email / lib / email.js
index 0f0f438..b300fb2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd666=['handleImapBox','handleImapEmail','bind','handleImapEnd','error','handleImapError','isNil','connected','messages','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','lastName','from','notify','then','Mail\x20accepted\x20from\x20routing','catch','lastSync','sendMail','send','Smtp','verify','exports','lodash','moment','socket.io-emitter','localhost','./imap','./smtp','email','../rpc/mailAccount','info','start\x20email\x20channel','mailAccounts','imapAccounts','smtp','prototype','emit','name','key','active','Imap','status','messageStatus','total','stringify','md5','mailAccount:update','refresh','hasOwnProperty','box'];(function(_0x412c8f,_0x11ec94){var _0x27c005=function(_0x127059){while(--_0x127059){_0x412c8f['push'](_0x412c8f['shift']());}};_0x27c005(++_0x11ec94);}(_0xd666,0x110));var _0x6d66=function(_0x3bf2d5,_0x36116c){_0x3bf2d5=_0x3bf2d5-0x0;var _0x29e958=_0xd666[_0x3bf2d5];return _0x29e958;};'use strict';var _=require(_0x6d66('0x0'));var moment=require(_0x6d66('0x1'));var BPromise=require('bluebird');var md5=require('md5');var io=require(_0x6d66('0x2'))({'host':_0x6d66('0x3'),'port':0x18eb});var EmailImap=require(_0x6d66('0x4'));var EmailSmtp=require(_0x6d66('0x5'));var logger=require('../../../config/logger')(_0x6d66('0x6'));var mailAccount=require(_0x6d66('0x7'));var md5Accounts={};function EmailChannel(_0xc6929c){logger[_0x6d66('0x8')](_0x6d66('0x9'));this['mailAccounts']=_0xc6929c[_0x6d66('0xa')];this[_0x6d66('0xb')]={};this[_0x6d66('0xc')]=new EmailSmtp();}EmailChannel[_0x6d66('0xd')][_0x6d66('0xe')]=function(_0x266db1){var _0x7d339b=this[_0x6d66('0xa')][_0x266db1];var _0x510ab6={'id':_0x7d339b['id'],'name':_0x7d339b[_0x6d66('0xf')],'key':_0x7d339b[_0x6d66('0x10')],'active':_0x7d339b[_0x6d66('0x11')],'Imap':{'status':_0x7d339b[_0x6d66('0x12')][_0x6d66('0x13')],'messageStatus':_0x7d339b[_0x6d66('0x12')][_0x6d66('0x14')],'total':_0x7d339b[_0x6d66('0x12')][_0x6d66('0x15')]}};if(_['isNil'](md5Accounts[_0x266db1])){md5Accounts[_0x266db1]={};}var _0xa138bb=md5(JSON[_0x6d66('0x16')](_0x510ab6));if(md5Accounts[_0x266db1][_0x6d66('0x17')]!==_0xa138bb){md5Accounts[_0x266db1][_0x6d66('0x17')]=_0xa138bb;io[_0x6d66('0xe')](_0x6d66('0x18'),_0x510ab6);}};EmailChannel['prototype'][_0x6d66('0x19')]=function(_0x2b5c04){for(var _0x3f954b in _0x2b5c04){if(_0x2b5c04[_0x6d66('0x1a')](_0x3f954b)){if(_0x2b5c04[_0x3f954b][_0x6d66('0x12')]&&_0x2b5c04[_0x3f954b][_0x6d66('0x11')]){var _0x24ca97=_0x2b5c04[_0x3f954b]['Imap'];if(!this[_0x6d66('0xb')][_0x6d66('0x1a')](_0x24ca97['id'])){this[_0x6d66('0xb')][_0x24ca97['id']]=new EmailImap(_0x24ca97,_0x2b5c04[_0x3f954b][_0x6d66('0x6')]);this[_0x6d66('0xb')][_0x24ca97['id']]['on'](_0x6d66('0x1b'),this[_0x6d66('0x1c')]['bind'](this,_0x3f954b));this[_0x6d66('0xb')][_0x24ca97['id']]['on'](_0x6d66('0x6'),this[_0x6d66('0x1d')][_0x6d66('0x1e')](this,_0x3f954b));this[_0x6d66('0xb')][_0x24ca97['id']]['on']('end',this[_0x6d66('0x1f')]['bind'](this,_0x3f954b));this[_0x6d66('0xb')][_0x24ca97['id']]['on'](_0x6d66('0x20'),this[_0x6d66('0x21')][_0x6d66('0x1e')](this,_0x3f954b));}}else{if(_[_0x6d66('0x22')](this[_0x6d66('0xa')][_0x3f954b][_0x6d66('0x12')])){this[_0x6d66('0xa')][_0x3f954b][_0x6d66('0x12')]={};}this[_0x6d66('0xa')][_0x3f954b]['Imap']['status']='disabled';this[_0x6d66('0xa')][_0x3f954b][_0x6d66('0x12')][_0x6d66('0x14')]='';this[_0x6d66('0xe')](_0x3f954b);}}}};EmailChannel[_0x6d66('0xd')]['handleImapBox']=function(_0x58a8d8,_0xf57789){if(this[_0x6d66('0xa')][_0x58a8d8]){this[_0x6d66('0xa')][_0x58a8d8][_0x6d66('0x12')][_0x6d66('0x13')]=_0x6d66('0x23');this[_0x6d66('0xa')][_0x58a8d8][_0x6d66('0x12')][_0x6d66('0x14')]=_0xf57789['name'];if(_0xf57789['messages']){this[_0x6d66('0xa')][_0x58a8d8][_0x6d66('0x12')][_0x6d66('0x15')]=_0xf57789[_0x6d66('0x24')]['total'];}return this[_0x6d66('0xe')](_0x58a8d8);}};EmailChannel[_0x6d66('0xd')]['handleImapEmail']=function(_0x6d2feb,_0x55cbc8){logger[_0x6d66('0x8')](_0x6d66('0x25'),_0x55cbc8['firstName'],_0x55cbc8[_0x6d66('0x26')],_0x55cbc8[_0x6d66('0x27')],_0x6d2feb);if(this[_0x6d66('0xa')][_0x6d2feb]){return mailAccount[_0x6d66('0x28')](_0x6d2feb,_0x55cbc8)[_0x6d66('0x29')](function(_0x437069){if(_0x437069){logger[_0x6d66('0x8')](_0x6d66('0x2a'));}})[_0x6d66('0x2b')](function(_0x3c2ffd){logger[_0x6d66('0x20')]('Mail\x20not\x20accepted\x20from\x20routing\x20%s',JSON[_0x6d66('0x16')](_0x3c2ffd));});}};EmailChannel['prototype'][_0x6d66('0x1f')]=function(_0x2ad381){if(this[_0x6d66('0xa')][_0x2ad381]&&this['mailAccounts'][_0x2ad381][_0x6d66('0x12')]){if(this[_0x6d66('0xb')][this[_0x6d66('0xa')][_0x2ad381][_0x6d66('0x12')]['id']]){delete this['imapAccounts'][this[_0x6d66('0xa')][_0x2ad381][_0x6d66('0x12')]['id']];}this[_0x6d66('0xa')][_0x2ad381][_0x6d66('0x12')][_0x6d66('0x2c')]=moment();this[_0x6d66('0xe')](_0x2ad381);}};EmailChannel[_0x6d66('0xd')]['handleImapError']=function(_0x3e5635,_0x30acbc){if(this['mailAccounts'][_0x3e5635]){this[_0x6d66('0xa')][_0x3e5635][_0x6d66('0x12')][_0x6d66('0x13')]=_0x6d66('0x20');this[_0x6d66('0xa')][_0x3e5635][_0x6d66('0x12')][_0x6d66('0x14')]=_0x30acbc;return this[_0x6d66('0xe')](_0x3e5635);}};EmailChannel[_0x6d66('0xd')][_0x6d66('0x2d')]=function(_0x2fb871,_0x10b8c2){return this[_0x6d66('0xc')][_0x6d66('0x2e')](_0x2fb871,_0x10b8c2);};EmailChannel[_0x6d66('0xd')]['verifySmtp']=function(_0x1e27ea){var _0x264846=this;if(this[_0x6d66('0xa')][_0x1e27ea['id']]){if(_[_0x6d66('0x22')](this['mailAccounts'][_0x1e27ea['id']][_0x6d66('0x2f')])){this[_0x6d66('0xa')][_0x1e27ea['id']][_0x6d66('0x2f')]={};}this[_0x6d66('0xa')][_0x1e27ea['id']][_0x6d66('0x2f')][_0x6d66('0x2c')]=moment();return new BPromise(function(_0x552755,_0x4f5fb0){return _0x264846[_0x6d66('0xc')][_0x6d66('0x30')](_0x1e27ea)[_0x6d66('0x29')](function(_0x517e25){_0x264846[_0x6d66('0xa')][_0x1e27ea['id']][_0x6d66('0x2f')][_0x6d66('0x13')]='verified';_0x264846[_0x6d66('0xa')][_0x1e27ea['id']]['Smtp']['messageStatus']='';_0x264846[_0x6d66('0xe')](_0x1e27ea['id']);_0x552755(_0x517e25);})['catch'](function(_0xbbfc7d){_0x264846['mailAccounts'][_0x1e27ea['id']][_0x6d66('0x2f')][_0x6d66('0x13')]=_0x6d66('0x20');_0x264846['mailAccounts'][_0x1e27ea['id']][_0x6d66('0x2f')][_0x6d66('0x14')]=_0xbbfc7d;_0x264846[_0x6d66('0xe')](_0x1e27ea['id']);_0x4f5fb0(_0xbbfc7d);});});}return this[_0x6d66('0xc')][_0x6d66('0x30')](_0x1e27ea);};module[_0x6d66('0x31')]=EmailChannel;
\ No newline at end of file
+var _0x29fa=['refresh','hasOwnProperty','imapAccounts','box','handleImapBox','bind','handleImapEmail','error','handleImapError','disabled','connected','name','messages','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','firstName','lastName','notify','then','Mail\x20accepted\x20from\x20routing','Mail\x20not\x20accepted\x20from\x20routing\x20%s','handleImapEnd','lastSync','sendMail','send','verifySmtp','Smtp','verify','verified','exports','lodash','moment','bluebird','md5','socket.io-emitter','./imap','../../../config/logger','email','../rpc/mailAccount','info','start\x20email\x20channel','mailAccounts','smtp','prototype','emit','key','active','Imap','status','messageStatus','total','isNil','stringify','mailAccount:update'];(function(_0x3116d6,_0x2d574f){var _0x18729d=function(_0x1945a0){while(--_0x1945a0){_0x3116d6['push'](_0x3116d6['shift']());}};_0x18729d(++_0x2d574f);}(_0x29fa,0x190));var _0xa29f=function(_0x382e89,_0x4768c0){_0x382e89=_0x382e89-0x0;var _0x3a1318=_0x29fa[_0x382e89];return _0x3a1318;};'use strict';var _=require(_0xa29f('0x0'));var moment=require(_0xa29f('0x1'));var BPromise=require(_0xa29f('0x2'));var md5=require(_0xa29f('0x3'));var io=require(_0xa29f('0x4'))({'host':'localhost','port':0x18eb});var EmailImap=require(_0xa29f('0x5'));var EmailSmtp=require('./smtp');var logger=require(_0xa29f('0x6'))(_0xa29f('0x7'));var mailAccount=require(_0xa29f('0x8'));var md5Accounts={};function EmailChannel(_0x26b3b5){logger[_0xa29f('0x9')](_0xa29f('0xa'));this[_0xa29f('0xb')]=_0x26b3b5[_0xa29f('0xb')];this['imapAccounts']={};this[_0xa29f('0xc')]=new EmailSmtp();}EmailChannel[_0xa29f('0xd')][_0xa29f('0xe')]=function(_0x3c7a3a){var _0x1b98d0=this['mailAccounts'][_0x3c7a3a];var _0x2084ce={'id':_0x1b98d0['id'],'name':_0x1b98d0['name'],'key':_0x1b98d0[_0xa29f('0xf')],'active':_0x1b98d0[_0xa29f('0x10')],'Imap':{'status':_0x1b98d0[_0xa29f('0x11')][_0xa29f('0x12')],'messageStatus':_0x1b98d0[_0xa29f('0x11')][_0xa29f('0x13')],'total':_0x1b98d0[_0xa29f('0x11')][_0xa29f('0x14')]}};if(_[_0xa29f('0x15')](md5Accounts[_0x3c7a3a])){md5Accounts[_0x3c7a3a]={};}var _0x159bc9=md5(JSON[_0xa29f('0x16')](_0x2084ce));if(md5Accounts[_0x3c7a3a][_0xa29f('0x3')]!==_0x159bc9){md5Accounts[_0x3c7a3a]['md5']=_0x159bc9;io['emit'](_0xa29f('0x17'),_0x2084ce);}};EmailChannel[_0xa29f('0xd')][_0xa29f('0x18')]=function(_0x354cbd){for(var _0x10ae53 in _0x354cbd){if(_0x354cbd[_0xa29f('0x19')](_0x10ae53)){if(_0x354cbd[_0x10ae53][_0xa29f('0x11')]&&_0x354cbd[_0x10ae53][_0xa29f('0x10')]){var _0x5598b4=_0x354cbd[_0x10ae53][_0xa29f('0x11')];if(!this[_0xa29f('0x1a')][_0xa29f('0x19')](_0x5598b4['id'])){this[_0xa29f('0x1a')][_0x5598b4['id']]=new EmailImap(_0x5598b4,_0x354cbd[_0x10ae53][_0xa29f('0x7')]);this[_0xa29f('0x1a')][_0x5598b4['id']]['on'](_0xa29f('0x1b'),this[_0xa29f('0x1c')][_0xa29f('0x1d')](this,_0x10ae53));this[_0xa29f('0x1a')][_0x5598b4['id']]['on'](_0xa29f('0x7'),this[_0xa29f('0x1e')][_0xa29f('0x1d')](this,_0x10ae53));this[_0xa29f('0x1a')][_0x5598b4['id']]['on']('end',this['handleImapEnd'][_0xa29f('0x1d')](this,_0x10ae53));this[_0xa29f('0x1a')][_0x5598b4['id']]['on'](_0xa29f('0x1f'),this[_0xa29f('0x20')][_0xa29f('0x1d')](this,_0x10ae53));}}else{if(_[_0xa29f('0x15')](this[_0xa29f('0xb')][_0x10ae53][_0xa29f('0x11')])){this[_0xa29f('0xb')][_0x10ae53][_0xa29f('0x11')]={};}this[_0xa29f('0xb')][_0x10ae53][_0xa29f('0x11')][_0xa29f('0x12')]=_0xa29f('0x21');this['mailAccounts'][_0x10ae53][_0xa29f('0x11')]['messageStatus']='';this['emit'](_0x10ae53);}}}};EmailChannel[_0xa29f('0xd')]['handleImapBox']=function(_0x3c5388,_0x595d1a){if(this[_0xa29f('0xb')][_0x3c5388]){this[_0xa29f('0xb')][_0x3c5388][_0xa29f('0x11')][_0xa29f('0x12')]=_0xa29f('0x22');this[_0xa29f('0xb')][_0x3c5388][_0xa29f('0x11')][_0xa29f('0x13')]=_0x595d1a[_0xa29f('0x23')];if(_0x595d1a[_0xa29f('0x24')]){this[_0xa29f('0xb')][_0x3c5388]['Imap'][_0xa29f('0x14')]=_0x595d1a['messages'][_0xa29f('0x14')];}return this[_0xa29f('0xe')](_0x3c5388);}};EmailChannel[_0xa29f('0xd')][_0xa29f('0x1e')]=function(_0xeef04e,_0x4decd7){logger[_0xa29f('0x9')](_0xa29f('0x25'),_0x4decd7[_0xa29f('0x26')],_0x4decd7[_0xa29f('0x27')],_0x4decd7['from'],_0xeef04e);if(this[_0xa29f('0xb')][_0xeef04e]){return mailAccount[_0xa29f('0x28')](_0xeef04e,_0x4decd7)[_0xa29f('0x29')](function(_0x5dd7b7){if(_0x5dd7b7){logger[_0xa29f('0x9')](_0xa29f('0x2a'));}})['catch'](function(_0x18f318){logger[_0xa29f('0x1f')](_0xa29f('0x2b'),JSON[_0xa29f('0x16')](_0x18f318));});}};EmailChannel[_0xa29f('0xd')][_0xa29f('0x2c')]=function(_0x4b04fd){if(this['mailAccounts'][_0x4b04fd]&&this[_0xa29f('0xb')][_0x4b04fd]['Imap']){if(this['imapAccounts'][this[_0xa29f('0xb')][_0x4b04fd][_0xa29f('0x11')]['id']]){delete this[_0xa29f('0x1a')][this[_0xa29f('0xb')][_0x4b04fd][_0xa29f('0x11')]['id']];}this[_0xa29f('0xb')][_0x4b04fd][_0xa29f('0x11')][_0xa29f('0x2d')]=moment();this[_0xa29f('0xe')](_0x4b04fd);}};EmailChannel[_0xa29f('0xd')][_0xa29f('0x20')]=function(_0x3435d,_0xee2d31){if(this[_0xa29f('0xb')][_0x3435d]){this[_0xa29f('0xb')][_0x3435d][_0xa29f('0x11')]['status']=_0xa29f('0x1f');this[_0xa29f('0xb')][_0x3435d]['Imap']['messageStatus']=_0xee2d31;return this[_0xa29f('0xe')](_0x3435d);}};EmailChannel[_0xa29f('0xd')][_0xa29f('0x2e')]=function(_0x74216,_0x2b78ff){return this[_0xa29f('0xc')][_0xa29f('0x2f')](_0x74216,_0x2b78ff);};EmailChannel[_0xa29f('0xd')][_0xa29f('0x30')]=function(_0x5e428b){var _0x44b21b=this;if(this['mailAccounts'][_0x5e428b['id']]){if(_[_0xa29f('0x15')](this['mailAccounts'][_0x5e428b['id']][_0xa29f('0x31')])){this[_0xa29f('0xb')][_0x5e428b['id']][_0xa29f('0x31')]={};}this[_0xa29f('0xb')][_0x5e428b['id']][_0xa29f('0x31')][_0xa29f('0x2d')]=moment();return new BPromise(function(_0x44ef34,_0x574349){return _0x44b21b[_0xa29f('0xc')][_0xa29f('0x32')](_0x5e428b)[_0xa29f('0x29')](function(_0xdcb3ac){_0x44b21b[_0xa29f('0xb')][_0x5e428b['id']]['Smtp'][_0xa29f('0x12')]=_0xa29f('0x33');_0x44b21b['mailAccounts'][_0x5e428b['id']][_0xa29f('0x31')][_0xa29f('0x13')]='';_0x44b21b[_0xa29f('0xe')](_0x5e428b['id']);_0x44ef34(_0xdcb3ac);})['catch'](function(_0x2418d7){_0x44b21b[_0xa29f('0xb')][_0x5e428b['id']][_0xa29f('0x31')][_0xa29f('0x12')]=_0xa29f('0x1f');_0x44b21b[_0xa29f('0xb')][_0x5e428b['id']]['Smtp'][_0xa29f('0x13')]=_0x2418d7;_0x44b21b[_0xa29f('0xe')](_0x5e428b['id']);_0x574349(_0x2418d7);});});}return this[_0xa29f('0xc')]['verify'](_0x5e428b);};module[_0xa29f('0x34')]=EmailChannel;
\ No newline at end of file