Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / services / email / lib / email.js
index ccf1c95..3a2ad78 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbc9f=['./imap','./smtp','../rpc/mailAccount','info','start\x20email\x20channel','mailAccounts','imapAccounts','smtp','prototype','emit','name','key','Imap','status','messageStatus','isNil','stringify','mailAccount:update','refresh','hasOwnProperty','active','email','box','handleImapBox','bind','handleImapEmail','end','handleImapEnd','error','handleImapError','disabled','messages','total','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','firstName','from','notify','then','Mail\x20accepted\x20from\x20routing','catch','Mail\x20not\x20accepted\x20from\x20routing\x20%s','lastSync','sendMail','verifySmtp','Smtp','verify','verified','exports','lodash','md5','ioredis','../../../config/logger','redis','localhost','socket.io-emitter'];(function(_0x3e4704,_0x371b8d){var _0x46f06c=function(_0x7d5e52){while(--_0x7d5e52){_0x3e4704['push'](_0x3e4704['shift']());}};_0x46f06c(++_0x371b8d);}(_0xbc9f,0x67));var _0xfbc9=function(_0x2eec1f,_0x1b9987){_0x2eec1f=_0x2eec1f-0x0;var _0x543075=_0xbc9f[_0x2eec1f];return _0x543075;};'use strict';var _=require(_0xfbc9('0x0'));var moment=require('moment');var BPromise=require('bluebird');var md5=require(_0xfbc9('0x1'));var Redis=require(_0xfbc9('0x2'));var config=require('../../../config/environment');var logger=require(_0xfbc9('0x3'))('email');config[_0xfbc9('0x4')]=_['defaults'](config['redis'],{'host':_0xfbc9('0x5'),'port':0x18eb});var io=require(_0xfbc9('0x6'))(new Redis(config['redis']));var EmailImap=require(_0xfbc9('0x7'));var EmailSmtp=require(_0xfbc9('0x8'));var mailAccount=require(_0xfbc9('0x9'));var md5Accounts={};function EmailChannel(_0x4508c3){logger[_0xfbc9('0xa')](_0xfbc9('0xb'));this[_0xfbc9('0xc')]=_0x4508c3[_0xfbc9('0xc')];this[_0xfbc9('0xd')]={};this[_0xfbc9('0xe')]=new EmailSmtp();}EmailChannel[_0xfbc9('0xf')][_0xfbc9('0x10')]=function(_0x16fa03){var _0x4c0ddc=this['mailAccounts'][_0x16fa03];var _0x29d882={'id':_0x4c0ddc['id'],'name':_0x4c0ddc[_0xfbc9('0x11')],'key':_0x4c0ddc[_0xfbc9('0x12')],'active':_0x4c0ddc['active'],'Imap':{'status':_0x4c0ddc[_0xfbc9('0x13')][_0xfbc9('0x14')],'messageStatus':_0x4c0ddc['Imap'][_0xfbc9('0x15')],'total':_0x4c0ddc[_0xfbc9('0x13')]['total']}};if(_[_0xfbc9('0x16')](md5Accounts[_0x16fa03])){md5Accounts[_0x16fa03]={};}var _0x2fad4c=md5(JSON[_0xfbc9('0x17')](_0x29d882));if(md5Accounts[_0x16fa03][_0xfbc9('0x1')]!==_0x2fad4c){md5Accounts[_0x16fa03][_0xfbc9('0x1')]=_0x2fad4c;io[_0xfbc9('0x10')](_0xfbc9('0x18'),_0x29d882);}};EmailChannel[_0xfbc9('0xf')][_0xfbc9('0x19')]=function(_0x28fe10){for(var _0x5933b5 in _0x28fe10){if(_0x28fe10[_0xfbc9('0x1a')](_0x5933b5)){if(_0x28fe10[_0x5933b5][_0xfbc9('0x13')]&&_0x28fe10[_0x5933b5][_0xfbc9('0x1b')]){var _0x3df255=_0x28fe10[_0x5933b5]['Imap'];if(!this[_0xfbc9('0xd')][_0xfbc9('0x1a')](_0x3df255['id'])){this[_0xfbc9('0xd')][_0x3df255['id']]=new EmailImap(_0x3df255,_0x28fe10[_0x5933b5][_0xfbc9('0x1c')]);this[_0xfbc9('0xd')][_0x3df255['id']]['on'](_0xfbc9('0x1d'),this[_0xfbc9('0x1e')][_0xfbc9('0x1f')](this,_0x5933b5));this['imapAccounts'][_0x3df255['id']]['on'](_0xfbc9('0x1c'),this[_0xfbc9('0x20')][_0xfbc9('0x1f')](this,_0x5933b5));this['imapAccounts'][_0x3df255['id']]['on'](_0xfbc9('0x21'),this[_0xfbc9('0x22')][_0xfbc9('0x1f')](this,_0x5933b5));this[_0xfbc9('0xd')][_0x3df255['id']]['on'](_0xfbc9('0x23'),this[_0xfbc9('0x24')][_0xfbc9('0x1f')](this,_0x5933b5));}}else{if(_[_0xfbc9('0x16')](this[_0xfbc9('0xc')][_0x5933b5]['Imap'])){this[_0xfbc9('0xc')][_0x5933b5][_0xfbc9('0x13')]={};}this['mailAccounts'][_0x5933b5][_0xfbc9('0x13')][_0xfbc9('0x14')]=_0xfbc9('0x25');this[_0xfbc9('0xc')][_0x5933b5][_0xfbc9('0x13')][_0xfbc9('0x15')]='';this[_0xfbc9('0x10')](_0x5933b5);}}}};EmailChannel['prototype'][_0xfbc9('0x1e')]=function(_0x150489,_0x1de9b1){if(this[_0xfbc9('0xc')][_0x150489]){this[_0xfbc9('0xc')][_0x150489][_0xfbc9('0x13')][_0xfbc9('0x14')]='connected';this[_0xfbc9('0xc')][_0x150489]['Imap'][_0xfbc9('0x15')]=_0x1de9b1[_0xfbc9('0x11')];if(_0x1de9b1[_0xfbc9('0x26')]){this[_0xfbc9('0xc')][_0x150489][_0xfbc9('0x13')]['total']=_0x1de9b1[_0xfbc9('0x26')][_0xfbc9('0x27')];}return this[_0xfbc9('0x10')](_0x150489);}};EmailChannel['prototype'][_0xfbc9('0x20')]=function(_0x18f61a,_0x2feb73){logger[_0xfbc9('0xa')](_0xfbc9('0x28'),_0x2feb73[_0xfbc9('0x29')],_0x2feb73['lastName'],_0x2feb73[_0xfbc9('0x2a')],_0x18f61a);if(this[_0xfbc9('0xc')][_0x18f61a]){return mailAccount[_0xfbc9('0x2b')](_0x18f61a,_0x2feb73)[_0xfbc9('0x2c')](function(_0x44c6fb){if(_0x44c6fb){logger[_0xfbc9('0xa')](_0xfbc9('0x2d'));}})[_0xfbc9('0x2e')](function(_0xc7acd0){logger[_0xfbc9('0x23')](_0xfbc9('0x2f'),JSON[_0xfbc9('0x17')](_0xc7acd0));});}};EmailChannel[_0xfbc9('0xf')][_0xfbc9('0x22')]=function(_0x39957d){if(this[_0xfbc9('0xc')][_0x39957d]&&this[_0xfbc9('0xc')][_0x39957d][_0xfbc9('0x13')]){if(this['imapAccounts'][this[_0xfbc9('0xc')][_0x39957d][_0xfbc9('0x13')]['id']]){delete this[_0xfbc9('0xd')][this['mailAccounts'][_0x39957d][_0xfbc9('0x13')]['id']];}this[_0xfbc9('0xc')][_0x39957d][_0xfbc9('0x13')][_0xfbc9('0x30')]=moment();this['emit'](_0x39957d);}};EmailChannel[_0xfbc9('0xf')][_0xfbc9('0x24')]=function(_0x58c049,_0x517cf8){if(this[_0xfbc9('0xc')][_0x58c049]){this[_0xfbc9('0xc')][_0x58c049][_0xfbc9('0x13')][_0xfbc9('0x14')]='error';this['mailAccounts'][_0x58c049][_0xfbc9('0x13')]['messageStatus']=_0x517cf8;return this['emit'](_0x58c049);}};EmailChannel['prototype'][_0xfbc9('0x31')]=function(_0xa0bfc2,_0x41a9f0){return this[_0xfbc9('0xe')]['send'](_0xa0bfc2,_0x41a9f0);};EmailChannel[_0xfbc9('0xf')][_0xfbc9('0x32')]=function(_0xf13050){var _0x4db283=this;if(this[_0xfbc9('0xc')][_0xf13050['id']]){if(_[_0xfbc9('0x16')](this[_0xfbc9('0xc')][_0xf13050['id']][_0xfbc9('0x33')])){this[_0xfbc9('0xc')][_0xf13050['id']][_0xfbc9('0x33')]={};}this['mailAccounts'][_0xf13050['id']]['Smtp'][_0xfbc9('0x30')]=moment();return new BPromise(function(_0x457cf8,_0xb15a23){return _0x4db283[_0xfbc9('0xe')][_0xfbc9('0x34')](_0xf13050)[_0xfbc9('0x2c')](function(_0x468fe8){_0x4db283[_0xfbc9('0xc')][_0xf13050['id']][_0xfbc9('0x33')][_0xfbc9('0x14')]=_0xfbc9('0x35');_0x4db283['mailAccounts'][_0xf13050['id']]['Smtp'][_0xfbc9('0x15')]='';_0x4db283[_0xfbc9('0x10')](_0xf13050['id']);_0x457cf8(_0x468fe8);})[_0xfbc9('0x2e')](function(_0x5d6349){_0x4db283[_0xfbc9('0xc')][_0xf13050['id']][_0xfbc9('0x33')][_0xfbc9('0x14')]='error';_0x4db283['mailAccounts'][_0xf13050['id']][_0xfbc9('0x33')][_0xfbc9('0x15')]=_0x5d6349;_0x4db283['emit'](_0xf13050['id']);_0xb15a23(_0x5d6349);});});}return this[_0xfbc9('0xe')][_0xfbc9('0x34')](_0xf13050);};module[_0xfbc9('0x36')]=EmailChannel;
\ No newline at end of file
+var _0xbf79=['sendMail','Smtp','verify','verified','catch','lodash','moment','bluebird','md5','ioredis','../../../config/environment','../../../config/logger','email','redis','defaults','socket.io-emitter','./smtp','../rpc/mailAccount','info','smtp','prototype','emit','key','active','Imap','messageStatus','total','isNil','stringify','mailAccount:update','refresh','hasOwnProperty','imapAccounts','box','handleImapBox','bind','handleImapEmail','error','mailAccounts','disabled','status','connected','name','messages','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','firstName','lastName','from','notify','then','Mail\x20accepted\x20from\x20routing','Mail\x20not\x20accepted\x20from\x20routing\x20%s','handleImapEnd','lastSync','handleImapError'];(function(_0x4d3a1f,_0x4c67c2){var _0x345ceb=function(_0x12ba3f){while(--_0x12ba3f){_0x4d3a1f['push'](_0x4d3a1f['shift']());}};_0x345ceb(++_0x4c67c2);}(_0xbf79,0x1bd));var _0x9bf7=function(_0x13fa2d,_0x34ca1e){_0x13fa2d=_0x13fa2d-0x0;var _0x28854c=_0xbf79[_0x13fa2d];return _0x28854c;};'use strict';var _=require(_0x9bf7('0x0'));var moment=require(_0x9bf7('0x1'));var BPromise=require(_0x9bf7('0x2'));var md5=require(_0x9bf7('0x3'));var Redis=require(_0x9bf7('0x4'));var config=require(_0x9bf7('0x5'));var logger=require(_0x9bf7('0x6'))(_0x9bf7('0x7'));config[_0x9bf7('0x8')]=_[_0x9bf7('0x9')](config[_0x9bf7('0x8')],{'host':'localhost','port':0x18eb});var io=require(_0x9bf7('0xa'))(new Redis(config[_0x9bf7('0x8')]));var EmailImap=require('./imap');var EmailSmtp=require(_0x9bf7('0xb'));var mailAccount=require(_0x9bf7('0xc'));var md5Accounts={};function EmailChannel(_0x7986d0){logger[_0x9bf7('0xd')]('start\x20email\x20channel');this['mailAccounts']=_0x7986d0['mailAccounts'];this['imapAccounts']={};this[_0x9bf7('0xe')]=new EmailSmtp();}EmailChannel[_0x9bf7('0xf')][_0x9bf7('0x10')]=function(_0x1a78ee){var _0x4a8db6=this['mailAccounts'][_0x1a78ee];var _0x2a5c99={'id':_0x4a8db6['id'],'name':_0x4a8db6['name'],'key':_0x4a8db6[_0x9bf7('0x11')],'active':_0x4a8db6[_0x9bf7('0x12')],'Imap':{'status':_0x4a8db6[_0x9bf7('0x13')]['status'],'messageStatus':_0x4a8db6[_0x9bf7('0x13')][_0x9bf7('0x14')],'total':_0x4a8db6[_0x9bf7('0x13')][_0x9bf7('0x15')]}};if(_[_0x9bf7('0x16')](md5Accounts[_0x1a78ee])){md5Accounts[_0x1a78ee]={};}var _0x57ab09=md5(JSON[_0x9bf7('0x17')](_0x2a5c99));if(md5Accounts[_0x1a78ee][_0x9bf7('0x3')]!==_0x57ab09){md5Accounts[_0x1a78ee][_0x9bf7('0x3')]=_0x57ab09;io['emit'](_0x9bf7('0x18'),_0x2a5c99);}};EmailChannel[_0x9bf7('0xf')][_0x9bf7('0x19')]=function(_0x18d848){for(var _0x3e7da8 in _0x18d848){if(_0x18d848[_0x9bf7('0x1a')](_0x3e7da8)){if(_0x18d848[_0x3e7da8][_0x9bf7('0x13')]&&_0x18d848[_0x3e7da8][_0x9bf7('0x12')]){var _0x10cb12=_0x18d848[_0x3e7da8]['Imap'];if(!this['imapAccounts'][_0x9bf7('0x1a')](_0x10cb12['id'])){this[_0x9bf7('0x1b')][_0x10cb12['id']]=new EmailImap(_0x10cb12,_0x18d848[_0x3e7da8][_0x9bf7('0x7')]);this[_0x9bf7('0x1b')][_0x10cb12['id']]['on'](_0x9bf7('0x1c'),this[_0x9bf7('0x1d')][_0x9bf7('0x1e')](this,_0x3e7da8));this[_0x9bf7('0x1b')][_0x10cb12['id']]['on']('email',this[_0x9bf7('0x1f')][_0x9bf7('0x1e')](this,_0x3e7da8));this[_0x9bf7('0x1b')][_0x10cb12['id']]['on']('end',this['handleImapEnd']['bind'](this,_0x3e7da8));this[_0x9bf7('0x1b')][_0x10cb12['id']]['on'](_0x9bf7('0x20'),this['handleImapError'][_0x9bf7('0x1e')](this,_0x3e7da8));}}else{if(_[_0x9bf7('0x16')](this[_0x9bf7('0x21')][_0x3e7da8]['Imap'])){this[_0x9bf7('0x21')][_0x3e7da8]['Imap']={};}this['mailAccounts'][_0x3e7da8]['Imap']['status']=_0x9bf7('0x22');this[_0x9bf7('0x21')][_0x3e7da8][_0x9bf7('0x13')][_0x9bf7('0x14')]='';this[_0x9bf7('0x10')](_0x3e7da8);}}}};EmailChannel[_0x9bf7('0xf')][_0x9bf7('0x1d')]=function(_0x5b61e0,_0x59418c){if(this[_0x9bf7('0x21')][_0x5b61e0]){this[_0x9bf7('0x21')][_0x5b61e0][_0x9bf7('0x13')][_0x9bf7('0x23')]=_0x9bf7('0x24');this[_0x9bf7('0x21')][_0x5b61e0][_0x9bf7('0x13')][_0x9bf7('0x14')]=_0x59418c[_0x9bf7('0x25')];if(_0x59418c[_0x9bf7('0x26')]){this[_0x9bf7('0x21')][_0x5b61e0]['Imap'][_0x9bf7('0x15')]=_0x59418c['messages']['total'];}return this[_0x9bf7('0x10')](_0x5b61e0);}};EmailChannel[_0x9bf7('0xf')][_0x9bf7('0x1f')]=function(_0x505a25,_0x5dabda){logger[_0x9bf7('0xd')](_0x9bf7('0x27'),_0x5dabda[_0x9bf7('0x28')],_0x5dabda[_0x9bf7('0x29')],_0x5dabda[_0x9bf7('0x2a')],_0x505a25);if(this[_0x9bf7('0x21')][_0x505a25]){return mailAccount[_0x9bf7('0x2b')](_0x505a25,_0x5dabda)[_0x9bf7('0x2c')](function(_0x50ec1f){if(_0x50ec1f){logger[_0x9bf7('0xd')](_0x9bf7('0x2d'));}})['catch'](function(_0x22bd88){logger[_0x9bf7('0x20')](_0x9bf7('0x2e'),JSON[_0x9bf7('0x17')](_0x22bd88));});}};EmailChannel[_0x9bf7('0xf')][_0x9bf7('0x2f')]=function(_0x43a92c){if(this['mailAccounts'][_0x43a92c]&&this[_0x9bf7('0x21')][_0x43a92c]['Imap']){if(this[_0x9bf7('0x1b')][this[_0x9bf7('0x21')][_0x43a92c]['Imap']['id']]){delete this['imapAccounts'][this[_0x9bf7('0x21')][_0x43a92c][_0x9bf7('0x13')]['id']];}this['mailAccounts'][_0x43a92c]['Imap'][_0x9bf7('0x30')]=moment();this[_0x9bf7('0x10')](_0x43a92c);}};EmailChannel['prototype'][_0x9bf7('0x31')]=function(_0x1c5208,_0xcfc2f5){if(this[_0x9bf7('0x21')][_0x1c5208]){this[_0x9bf7('0x21')][_0x1c5208]['Imap'][_0x9bf7('0x23')]=_0x9bf7('0x20');this[_0x9bf7('0x21')][_0x1c5208][_0x9bf7('0x13')][_0x9bf7('0x14')]=_0xcfc2f5;return this[_0x9bf7('0x10')](_0x1c5208);}};EmailChannel[_0x9bf7('0xf')][_0x9bf7('0x32')]=function(_0x444935,_0xeb2f93){return this['smtp']['send'](_0x444935,_0xeb2f93);};EmailChannel[_0x9bf7('0xf')]['verifySmtp']=function(_0xfab2f5){var _0x31d68d=this;if(this[_0x9bf7('0x21')][_0xfab2f5['id']]){if(_[_0x9bf7('0x16')](this[_0x9bf7('0x21')][_0xfab2f5['id']][_0x9bf7('0x33')])){this['mailAccounts'][_0xfab2f5['id']]['Smtp']={};}this[_0x9bf7('0x21')][_0xfab2f5['id']][_0x9bf7('0x33')]['lastSync']=moment();return new BPromise(function(_0x1e9792,_0x21827f){return _0x31d68d[_0x9bf7('0xe')][_0x9bf7('0x34')](_0xfab2f5)[_0x9bf7('0x2c')](function(_0x5ccb1c){_0x31d68d['mailAccounts'][_0xfab2f5['id']][_0x9bf7('0x33')][_0x9bf7('0x23')]=_0x9bf7('0x35');_0x31d68d[_0x9bf7('0x21')][_0xfab2f5['id']][_0x9bf7('0x33')][_0x9bf7('0x14')]='';_0x31d68d[_0x9bf7('0x10')](_0xfab2f5['id']);_0x1e9792(_0x5ccb1c);})[_0x9bf7('0x36')](function(_0x1fcecf){_0x31d68d[_0x9bf7('0x21')][_0xfab2f5['id']][_0x9bf7('0x33')][_0x9bf7('0x23')]=_0x9bf7('0x20');_0x31d68d[_0x9bf7('0x21')][_0xfab2f5['id']][_0x9bf7('0x33')][_0x9bf7('0x14')]=_0x1fcecf;_0x31d68d[_0x9bf7('0x10')](_0xfab2f5['id']);_0x21827f(_0x1fcecf);});});}return this[_0x9bf7('0xe')][_0x9bf7('0x34')](_0xfab2f5);};module['exports']=EmailChannel;
\ No newline at end of file