Built motion from commit (unavailable).|2.3.1
[motion2.git] / server / services / email / lib / email.js
index c72db91..17c722a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6ac2=['handleImapEmail','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','firstName','lastName','from','notify','catch','Mail\x20not\x20accepted\x20from\x20routing\x20%s','lastSync','emit','send','verifySmtp','isNil','Smtp','verified','verify','exports','lodash','bluebird','md5','ioredis','../../../config/environment','../../../config/logger','email','defaults','localhost','socket.io-emitter','redis','./imap','./smtp','../rpc/mailAccount','info','mailAccounts','imapAccounts','smtp','prototype','active','Imap','status','messageStatus','total','stringify','mailAccount:update','hasOwnProperty','box','bind','end','handleImapEnd','error','handleImapError','disabled','name','messages'];(function(_0xdfa07f,_0x17cd1c){var _0x11387d=function(_0xec67ec){while(--_0xec67ec){_0xdfa07f['push'](_0xdfa07f['shift']());}};_0x11387d(++_0x17cd1c);}(_0x6ac2,0x184));var _0x26ac=function(_0x206d6e,_0x455640){_0x206d6e=_0x206d6e-0x0;var _0x531150=_0x6ac2[_0x206d6e];return _0x531150;};'use strict';var _=require(_0x26ac('0x0'));var moment=require('moment');var BPromise=require(_0x26ac('0x1'));var md5=require(_0x26ac('0x2'));var Redis=require(_0x26ac('0x3'));var config=require(_0x26ac('0x4'));var logger=require(_0x26ac('0x5'))(_0x26ac('0x6'));config['redis']=_[_0x26ac('0x7')](config['redis'],{'host':_0x26ac('0x8'),'port':0x18eb});var io=require(_0x26ac('0x9'))(new Redis(config[_0x26ac('0xa')]));var EmailImap=require(_0x26ac('0xb'));var EmailSmtp=require(_0x26ac('0xc'));var mailAccount=require(_0x26ac('0xd'));var md5Accounts={};function EmailChannel(_0x1906d0){logger[_0x26ac('0xe')]('start\x20email\x20channel');this['mailAccounts']=_0x1906d0[_0x26ac('0xf')];this[_0x26ac('0x10')]={};this[_0x26ac('0x11')]=new EmailSmtp();}EmailChannel[_0x26ac('0x12')]['emit']=function(_0x11e8a1){var _0x2507f9=this[_0x26ac('0xf')][_0x11e8a1];var _0x11246b={'id':_0x2507f9['id'],'name':_0x2507f9['name'],'key':_0x2507f9['key'],'active':_0x2507f9[_0x26ac('0x13')],'Imap':{'status':_0x2507f9[_0x26ac('0x14')][_0x26ac('0x15')],'messageStatus':_0x2507f9[_0x26ac('0x14')][_0x26ac('0x16')],'total':_0x2507f9[_0x26ac('0x14')][_0x26ac('0x17')]}};if(_['isNil'](md5Accounts[_0x11e8a1])){md5Accounts[_0x11e8a1]={};}var _0x2f68ad=md5(JSON[_0x26ac('0x18')](_0x11246b));if(md5Accounts[_0x11e8a1][_0x26ac('0x2')]!==_0x2f68ad){md5Accounts[_0x11e8a1][_0x26ac('0x2')]=_0x2f68ad;io['emit'](_0x26ac('0x19'),_0x11246b);}};EmailChannel[_0x26ac('0x12')]['refresh']=function(_0x3dca1f){for(var _0x3b1300 in _0x3dca1f){if(_0x3dca1f[_0x26ac('0x1a')](_0x3b1300)){if(_0x3dca1f[_0x3b1300][_0x26ac('0x14')]&&_0x3dca1f[_0x3b1300]['active']){var _0xfb304b=_0x3dca1f[_0x3b1300][_0x26ac('0x14')];if(!this['imapAccounts']['hasOwnProperty'](_0xfb304b['id'])){this[_0x26ac('0x10')][_0xfb304b['id']]=new EmailImap(_0xfb304b,_0x3dca1f[_0x3b1300][_0x26ac('0x6')]);this['imapAccounts'][_0xfb304b['id']]['on'](_0x26ac('0x1b'),this['handleImapBox']['bind'](this,_0x3b1300));this['imapAccounts'][_0xfb304b['id']]['on'](_0x26ac('0x6'),this['handleImapEmail'][_0x26ac('0x1c')](this,_0x3b1300));this[_0x26ac('0x10')][_0xfb304b['id']]['on'](_0x26ac('0x1d'),this[_0x26ac('0x1e')][_0x26ac('0x1c')](this,_0x3b1300));this[_0x26ac('0x10')][_0xfb304b['id']]['on'](_0x26ac('0x1f'),this[_0x26ac('0x20')][_0x26ac('0x1c')](this,_0x3b1300));}}else{if(_['isNil'](this[_0x26ac('0xf')][_0x3b1300][_0x26ac('0x14')])){this[_0x26ac('0xf')][_0x3b1300][_0x26ac('0x14')]={};}this[_0x26ac('0xf')][_0x3b1300][_0x26ac('0x14')][_0x26ac('0x15')]=_0x26ac('0x21');this[_0x26ac('0xf')][_0x3b1300][_0x26ac('0x14')]['messageStatus']='';this['emit'](_0x3b1300);}}}};EmailChannel[_0x26ac('0x12')]['handleImapBox']=function(_0x185296,_0x11b8de){if(this[_0x26ac('0xf')][_0x185296]){this[_0x26ac('0xf')][_0x185296][_0x26ac('0x14')][_0x26ac('0x15')]='connected';this['mailAccounts'][_0x185296][_0x26ac('0x14')][_0x26ac('0x16')]=_0x11b8de[_0x26ac('0x22')];if(_0x11b8de['messages']){this['mailAccounts'][_0x185296][_0x26ac('0x14')][_0x26ac('0x17')]=_0x11b8de[_0x26ac('0x23')][_0x26ac('0x17')];}return this['emit'](_0x185296);}};EmailChannel['prototype'][_0x26ac('0x24')]=function(_0x3e2148,_0x17691a){logger[_0x26ac('0xe')](_0x26ac('0x25'),_0x17691a[_0x26ac('0x26')],_0x17691a[_0x26ac('0x27')],_0x17691a[_0x26ac('0x28')],_0x3e2148);if(this[_0x26ac('0xf')][_0x3e2148]){return mailAccount[_0x26ac('0x29')](_0x3e2148,_0x17691a)['then'](function(_0x10afd8){if(_0x10afd8){logger[_0x26ac('0xe')]('Mail\x20accepted\x20from\x20routing');}})[_0x26ac('0x2a')](function(_0x3b6e75){logger[_0x26ac('0x1f')](_0x26ac('0x2b'),JSON[_0x26ac('0x18')](_0x3b6e75));});}};EmailChannel[_0x26ac('0x12')][_0x26ac('0x1e')]=function(_0xeda527){if(this[_0x26ac('0xf')][_0xeda527]&&this[_0x26ac('0xf')][_0xeda527][_0x26ac('0x14')]){if(this[_0x26ac('0x10')][this['mailAccounts'][_0xeda527][_0x26ac('0x14')]['id']]){delete this[_0x26ac('0x10')][this[_0x26ac('0xf')][_0xeda527]['Imap']['id']];}this[_0x26ac('0xf')][_0xeda527]['Imap'][_0x26ac('0x2c')]=moment();this[_0x26ac('0x2d')](_0xeda527);}};EmailChannel['prototype'][_0x26ac('0x20')]=function(_0x489e61,_0x28850f){if(this[_0x26ac('0xf')][_0x489e61]){this[_0x26ac('0xf')][_0x489e61][_0x26ac('0x14')]['status']=_0x26ac('0x1f');this['mailAccounts'][_0x489e61][_0x26ac('0x14')]['messageStatus']=_0x28850f;return this[_0x26ac('0x2d')](_0x489e61);}};EmailChannel['prototype']['sendMail']=function(_0x287937,_0x1861eb){return this[_0x26ac('0x11')][_0x26ac('0x2e')](_0x287937,_0x1861eb);};EmailChannel[_0x26ac('0x12')][_0x26ac('0x2f')]=function(_0x506a92){var _0x5c89bb=this;if(this[_0x26ac('0xf')][_0x506a92['id']]){if(_[_0x26ac('0x30')](this[_0x26ac('0xf')][_0x506a92['id']]['Smtp'])){this['mailAccounts'][_0x506a92['id']][_0x26ac('0x31')]={};}this[_0x26ac('0xf')][_0x506a92['id']]['Smtp']['lastSync']=moment();return new BPromise(function(_0x33361b,_0x382de7){return _0x5c89bb[_0x26ac('0x11')]['verify'](_0x506a92)['then'](function(_0x4bde52){_0x5c89bb['mailAccounts'][_0x506a92['id']][_0x26ac('0x31')][_0x26ac('0x15')]=_0x26ac('0x32');_0x5c89bb[_0x26ac('0xf')][_0x506a92['id']][_0x26ac('0x31')][_0x26ac('0x16')]='';_0x5c89bb[_0x26ac('0x2d')](_0x506a92['id']);_0x33361b(_0x4bde52);})[_0x26ac('0x2a')](function(_0xcbc052){_0x5c89bb['mailAccounts'][_0x506a92['id']][_0x26ac('0x31')][_0x26ac('0x15')]=_0x26ac('0x1f');_0x5c89bb[_0x26ac('0xf')][_0x506a92['id']][_0x26ac('0x31')][_0x26ac('0x16')]=_0xcbc052;_0x5c89bb[_0x26ac('0x2d')](_0x506a92['id']);_0x382de7(_0xcbc052);});});}return this[_0x26ac('0x11')][_0x26ac('0x33')](_0x506a92);};module[_0x26ac('0x34')]=EmailChannel;
\ No newline at end of file
+var _0xbd10=['email','bind','handleImapEmail','end','handleImapEnd','error','handleImapError','isNil','disabled','messages','New\x20email\x20from\x20%s\x20%s\x20%s\x20to\x20%s','firstName','from','Mail\x20accepted\x20from\x20routing','catch','Mail\x20not\x20accepted\x20from\x20routing\x20%s','lastSync','sendMail','send','verifySmtp','Smtp','then','verified','verify','exports','lodash','moment','bluebird','ioredis','../../../config/environment','../../../config/logger','redis','defaults','localhost','socket.io-emitter','./smtp','info','start\x20email\x20channel','mailAccounts','imapAccounts','smtp','prototype','emit','name','key','active','Imap','status','messageStatus','total','stringify','md5','refresh','hasOwnProperty'];(function(_0x28c91d,_0x3e761e){var _0x1d31aa=function(_0x5ea2c0){while(--_0x5ea2c0){_0x28c91d['push'](_0x28c91d['shift']());}};_0x1d31aa(++_0x3e761e);}(_0xbd10,0x85));var _0x0bd1=function(_0x404364,_0x40ca63){_0x404364=_0x404364-0x0;var _0x146fe3=_0xbd10[_0x404364];return _0x146fe3;};'use strict';var _=require(_0x0bd1('0x0'));var moment=require(_0x0bd1('0x1'));var BPromise=require(_0x0bd1('0x2'));var md5=require('md5');var Redis=require(_0x0bd1('0x3'));var config=require(_0x0bd1('0x4'));var logger=require(_0x0bd1('0x5'))('email');config[_0x0bd1('0x6')]=_[_0x0bd1('0x7')](config[_0x0bd1('0x6')],{'host':_0x0bd1('0x8'),'port':0x18eb});var io=require(_0x0bd1('0x9'))(new Redis(config[_0x0bd1('0x6')]));var EmailImap=require('./imap');var EmailSmtp=require(_0x0bd1('0xa'));var mailAccount=require('../rpc/mailAccount');var md5Accounts={};function EmailChannel(_0x639350){logger[_0x0bd1('0xb')](_0x0bd1('0xc'));this[_0x0bd1('0xd')]=_0x639350['mailAccounts'];this[_0x0bd1('0xe')]={};this[_0x0bd1('0xf')]=new EmailSmtp();}EmailChannel[_0x0bd1('0x10')][_0x0bd1('0x11')]=function(_0x154b4f){var _0x216523=this['mailAccounts'][_0x154b4f];var _0x159b15={'id':_0x216523['id'],'name':_0x216523[_0x0bd1('0x12')],'key':_0x216523[_0x0bd1('0x13')],'active':_0x216523[_0x0bd1('0x14')],'Imap':{'status':_0x216523[_0x0bd1('0x15')][_0x0bd1('0x16')],'messageStatus':_0x216523['Imap'][_0x0bd1('0x17')],'total':_0x216523[_0x0bd1('0x15')][_0x0bd1('0x18')]}};if(_['isNil'](md5Accounts[_0x154b4f])){md5Accounts[_0x154b4f]={};}var _0x51f988=md5(JSON[_0x0bd1('0x19')](_0x159b15));if(md5Accounts[_0x154b4f][_0x0bd1('0x1a')]!==_0x51f988){md5Accounts[_0x154b4f][_0x0bd1('0x1a')]=_0x51f988;io['emit']('mailAccount:update',_0x159b15);}};EmailChannel[_0x0bd1('0x10')][_0x0bd1('0x1b')]=function(_0xc96c4d){for(var _0x5ab359 in _0xc96c4d){if(_0xc96c4d[_0x0bd1('0x1c')](_0x5ab359)){if(_0xc96c4d[_0x5ab359][_0x0bd1('0x15')]&&_0xc96c4d[_0x5ab359][_0x0bd1('0x14')]){var _0x3042c6=_0xc96c4d[_0x5ab359]['Imap'];if(!this[_0x0bd1('0xe')][_0x0bd1('0x1c')](_0x3042c6['id'])){this['imapAccounts'][_0x3042c6['id']]=new EmailImap(_0x3042c6,_0xc96c4d[_0x5ab359][_0x0bd1('0x1d')]);this[_0x0bd1('0xe')][_0x3042c6['id']]['on']('box',this['handleImapBox'][_0x0bd1('0x1e')](this,_0x5ab359));this[_0x0bd1('0xe')][_0x3042c6['id']]['on'](_0x0bd1('0x1d'),this[_0x0bd1('0x1f')][_0x0bd1('0x1e')](this,_0x5ab359));this[_0x0bd1('0xe')][_0x3042c6['id']]['on'](_0x0bd1('0x20'),this[_0x0bd1('0x21')]['bind'](this,_0x5ab359));this[_0x0bd1('0xe')][_0x3042c6['id']]['on'](_0x0bd1('0x22'),this[_0x0bd1('0x23')][_0x0bd1('0x1e')](this,_0x5ab359));}}else{if(_[_0x0bd1('0x24')](this['mailAccounts'][_0x5ab359][_0x0bd1('0x15')])){this['mailAccounts'][_0x5ab359]['Imap']={};}this[_0x0bd1('0xd')][_0x5ab359][_0x0bd1('0x15')][_0x0bd1('0x16')]=_0x0bd1('0x25');this[_0x0bd1('0xd')][_0x5ab359][_0x0bd1('0x15')][_0x0bd1('0x17')]='';this[_0x0bd1('0x11')](_0x5ab359);}}}};EmailChannel[_0x0bd1('0x10')]['handleImapBox']=function(_0x5cb236,_0x3250f6){if(this['mailAccounts'][_0x5cb236]){this[_0x0bd1('0xd')][_0x5cb236][_0x0bd1('0x15')]['status']='connected';this['mailAccounts'][_0x5cb236]['Imap']['messageStatus']=_0x3250f6[_0x0bd1('0x12')];if(_0x3250f6[_0x0bd1('0x26')]){this[_0x0bd1('0xd')][_0x5cb236]['Imap'][_0x0bd1('0x18')]=_0x3250f6[_0x0bd1('0x26')]['total'];}return this['emit'](_0x5cb236);}};EmailChannel[_0x0bd1('0x10')]['handleImapEmail']=function(_0x5366c4,_0x47980f){logger[_0x0bd1('0xb')](_0x0bd1('0x27'),_0x47980f[_0x0bd1('0x28')],_0x47980f['lastName'],_0x47980f[_0x0bd1('0x29')],_0x5366c4);if(this[_0x0bd1('0xd')][_0x5366c4]){return mailAccount['notify'](_0x5366c4,_0x47980f)['then'](function(_0x28877b){if(_0x28877b){logger['info'](_0x0bd1('0x2a'));}})[_0x0bd1('0x2b')](function(_0x5dbab4){logger[_0x0bd1('0x22')](_0x0bd1('0x2c'),JSON[_0x0bd1('0x19')](_0x5dbab4));});}};EmailChannel['prototype'][_0x0bd1('0x21')]=function(_0x4e79f4){if(this[_0x0bd1('0xd')][_0x4e79f4]&&this[_0x0bd1('0xd')][_0x4e79f4][_0x0bd1('0x15')]){if(this[_0x0bd1('0xe')][this['mailAccounts'][_0x4e79f4][_0x0bd1('0x15')]['id']]){delete this[_0x0bd1('0xe')][this[_0x0bd1('0xd')][_0x4e79f4][_0x0bd1('0x15')]['id']];}this[_0x0bd1('0xd')][_0x4e79f4][_0x0bd1('0x15')][_0x0bd1('0x2d')]=moment();this['emit'](_0x4e79f4);}};EmailChannel[_0x0bd1('0x10')][_0x0bd1('0x23')]=function(_0x488310,_0x224159){if(this[_0x0bd1('0xd')][_0x488310]){this[_0x0bd1('0xd')][_0x488310][_0x0bd1('0x15')][_0x0bd1('0x16')]=_0x0bd1('0x22');this[_0x0bd1('0xd')][_0x488310][_0x0bd1('0x15')][_0x0bd1('0x17')]=_0x224159;return this[_0x0bd1('0x11')](_0x488310);}};EmailChannel[_0x0bd1('0x10')][_0x0bd1('0x2e')]=function(_0x41ee78,_0x217c77){return this[_0x0bd1('0xf')][_0x0bd1('0x2f')](_0x41ee78,_0x217c77);};EmailChannel[_0x0bd1('0x10')][_0x0bd1('0x30')]=function(_0x54e3aa){var _0x5246fd=this;if(this[_0x0bd1('0xd')][_0x54e3aa['id']]){if(_[_0x0bd1('0x24')](this[_0x0bd1('0xd')][_0x54e3aa['id']][_0x0bd1('0x31')])){this[_0x0bd1('0xd')][_0x54e3aa['id']][_0x0bd1('0x31')]={};}this['mailAccounts'][_0x54e3aa['id']]['Smtp'][_0x0bd1('0x2d')]=moment();return new BPromise(function(_0x469905,_0x22c0b2){return _0x5246fd[_0x0bd1('0xf')]['verify'](_0x54e3aa)[_0x0bd1('0x32')](function(_0x5581da){_0x5246fd[_0x0bd1('0xd')][_0x54e3aa['id']]['Smtp'][_0x0bd1('0x16')]=_0x0bd1('0x33');_0x5246fd[_0x0bd1('0xd')][_0x54e3aa['id']][_0x0bd1('0x31')]['messageStatus']='';_0x5246fd[_0x0bd1('0x11')](_0x54e3aa['id']);_0x469905(_0x5581da);})[_0x0bd1('0x2b')](function(_0x3ac038){_0x5246fd['mailAccounts'][_0x54e3aa['id']][_0x0bd1('0x31')][_0x0bd1('0x16')]=_0x0bd1('0x22');_0x5246fd[_0x0bd1('0xd')][_0x54e3aa['id']][_0x0bd1('0x31')][_0x0bd1('0x17')]=_0x3ac038;_0x5246fd[_0x0bd1('0x11')](_0x54e3aa['id']);_0x22c0b2(_0x3ac038);});});}return this[_0x0bd1('0xf')][_0x0bd1('0x34')](_0x54e3aa);};module[_0x0bd1('0x35')]=EmailChannel;
\ No newline at end of file