Built motion from commit 7158bc59.|2.5.42
[motion2.git] / server / services / email / lib / imap.js
index a958193..a29f6d2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd8fb=['box','readUnseen','handleCloseBox','end','search','UNSEEN','handleReadUnseen','fetch','message','handleFetchError','handleFetchEnd','closeBox','handleFetchMessage','body','handleMessageBody','handleMessageAttributes','handleMessageEnd','handleSimpleParser','parser','handleEnd','account','stringify','upperFirst','emit','exports','lodash','util','imap','mailparser','events','EventEmitter','../../../config/logger','email','INBOX','getAccount','once','ready','handleReady','bind','error','connect','inherits','prototype','connTimeout','authTimeout','isNil','authentication','user','password','host','port','tls','required','xoauth2','generateXOAuth2Token','CloudProvider','data5','getHost','service','anonymous@xcally.com','openBox','mailbox','handleOpenBox','handleError'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0xd8fb,0x99));var _0xbd8f=function(_0x8e00d3,_0x5d02b6){_0x8e00d3=_0x8e00d3-0x0;var _0x13c585=_0xd8fb[_0x8e00d3];return _0x13c585;};'use strict';var _=require(_0xbd8f('0x0'));var util=require(_0xbd8f('0x1'));var Imap=require(_0xbd8f('0x2'));var simpleParser=require(_0xbd8f('0x3'))['simpleParser'];var Iconv=require('iconv')['Iconv'];var EventEmitter=require(_0xbd8f('0x4'))[_0xbd8f('0x5')];var utils=require('./utils');var logger=require(_0xbd8f('0x6'))(_0xbd8f('0x7'));function EmailImap(_0x5543b2,_0x33d541){this['mailbox']=_0xbd8f('0x8');this['account']=this[_0xbd8f('0x9')](_0x5543b2,_0x33d541);this[_0xbd8f('0x2')]=new Imap(this['account']);this['imap'][_0xbd8f('0xa')](_0xbd8f('0xb'),this[_0xbd8f('0xc')]['bind'](this));this[_0xbd8f('0x2')][_0xbd8f('0xa')]('end',this['handleEnd'][_0xbd8f('0xd')](this));this[_0xbd8f('0x2')]['on'](_0xbd8f('0xe'),this['handleError'][_0xbd8f('0xd')](this));this[_0xbd8f('0x2')][_0xbd8f('0xf')]();}util[_0xbd8f('0x10')](EmailImap,EventEmitter);EmailImap[_0xbd8f('0x11')][_0xbd8f('0x9')]=function(_0x37d4d5,_0x29ffe8){var _0x14606c={'connTimeout':_0x37d4d5['connTimeout']?_0x37d4d5[_0xbd8f('0x12')]*0x3e8:0x2710,'authTimeout':_0x37d4d5[_0xbd8f('0x13')]?_0x37d4d5[_0xbd8f('0x13')]*0x3e8:0x1388};if(_[_0xbd8f('0x14')](_0x37d4d5['service'])){if(_0x37d4d5[_0xbd8f('0x15')]){_0x14606c[_0xbd8f('0x16')]=_0x37d4d5['user'];_0x14606c[_0xbd8f('0x17')]=_0x37d4d5[_0xbd8f('0x17')];}_0x14606c['host']=_0x37d4d5[_0xbd8f('0x18')];_0x14606c[_0xbd8f('0x19')]=_0x37d4d5['port']||0x3e1;if(_0x37d4d5['tls']){_0x14606c[_0xbd8f('0x1a')]=!![];}else{_0x14606c['tls']=![];_0x14606c['autotls']=_0xbd8f('0x1b');}}else{if(_0x37d4d5['modernAuthentication']){_0x14606c[_0xbd8f('0x1c')]=utils[_0xbd8f('0x1d')](_0x37d4d5[_0xbd8f('0x1e')][_0xbd8f('0x1f')],_0x37d4d5[_0xbd8f('0x16')]);_0x14606c[_0xbd8f('0x16')]=_0x37d4d5[_0xbd8f('0x16')];}else{_0x14606c[_0xbd8f('0x16')]=_0x37d4d5[_0xbd8f('0x16')];_0x14606c[_0xbd8f('0x17')]=_0x37d4d5[_0xbd8f('0x17')];}_0x14606c[_0xbd8f('0x18')]=utils[_0xbd8f('0x20')](_0x37d4d5[_0xbd8f('0x21')]);_0x14606c[_0xbd8f('0x19')]=0x3e1;_0x14606c[_0xbd8f('0x1a')]=!![];}_0x14606c[_0xbd8f('0x7')]=_0x29ffe8||_0x37d4d5['user']||_0xbd8f('0x22');return _0x14606c;};EmailImap[_0xbd8f('0x11')][_0xbd8f('0xc')]=function(){this[_0xbd8f('0x2')][_0xbd8f('0x23')](this[_0xbd8f('0x24')],![],this[_0xbd8f('0x25')][_0xbd8f('0xd')](this));};EmailImap['prototype'][_0xbd8f('0x25')]=function(_0x421f3e,_0x5a3a8c){if(_0x421f3e){this[_0xbd8f('0x26')](_0x421f3e,!![]);}else{this['emit'](_0xbd8f('0x27'),_0x5a3a8c);this[_0xbd8f('0x28')]();}};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x29')]=function(_0x2aefa2){if(_0x2aefa2){this[_0xbd8f('0x26')](_0x2aefa2,!![]);}else{this['imap'][_0xbd8f('0x2a')]();}};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x28')]=function(){this[_0xbd8f('0x2')][_0xbd8f('0x2b')]([_0xbd8f('0x2c')],this[_0xbd8f('0x2d')]['bind'](this));};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x2d')]=function(_0xb9214c,_0x7ca145){if(_0xb9214c){this['handleError'](_0xb9214c,!![]);}else{if(_0x7ca145['length']){try{var _0x1c2274=this[_0xbd8f('0x2')][_0xbd8f('0x2e')](_0x7ca145,{'bodies':'','markSeen':!![]});_0x1c2274['on'](_0xbd8f('0x2f'),this['handleFetchMessage'][_0xbd8f('0xd')](this));_0x1c2274[_0xbd8f('0xa')](_0xbd8f('0xe'),this[_0xbd8f('0x30')][_0xbd8f('0xd')](this));_0x1c2274['once'](_0xbd8f('0x2a'),this[_0xbd8f('0x31')][_0xbd8f('0xd')](this));}catch(_0x3949c2){logger[_0xbd8f('0xe')](_0x3949c2);}}else{this['imap'][_0xbd8f('0x32')](!![],this['handleCloseBox'][_0xbd8f('0xd')](this));}}};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x33')]=function(_0x386a29){_0x386a29['on'](_0xbd8f('0x34'),this[_0xbd8f('0x35')]['bind'](this));_0x386a29['once']('attributes',this[_0xbd8f('0x36')][_0xbd8f('0xd')](this));_0x386a29[_0xbd8f('0xa')](_0xbd8f('0x2a'),this[_0xbd8f('0x37')][_0xbd8f('0xd')](this));};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x35')]=function(_0x2d4882){simpleParser(_0x2d4882,{'Iconv':Iconv},this[_0xbd8f('0x38')][_0xbd8f('0xd')](this));};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x36')]=function(){};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x37')]=function(){};EmailImap['prototype'][_0xbd8f('0x38')]=function(_0x4181e0,_0x47f9cd){if(_0x4181e0){logger[_0xbd8f('0xe')](_0x4181e0);}else{var _0x40204a=this;utils[_0xbd8f('0x39')](this['account'],_0x47f9cd,function(_0x21da54){_0x40204a['emit'](_0xbd8f('0x7'),_0x21da54);});}};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x31')]=function(){this['imap'][_0xbd8f('0x32')](!![],this[_0xbd8f('0x29')][_0xbd8f('0xd')](this));};EmailImap['prototype'][_0xbd8f('0x30')]=function(_0x3d82ef){this[_0xbd8f('0x26')](_0x3d82ef);this[_0xbd8f('0x2')][_0xbd8f('0x32')](!![],this[_0xbd8f('0x29')][_0xbd8f('0xd')](this));};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x3a')]=function(){this['emit']('end');};EmailImap[_0xbd8f('0x11')][_0xbd8f('0x26')]=function(_0x353e34,_0x2f014b){logger['error'](_0xbd8f('0x26'),this[_0xbd8f('0x3b')][_0xbd8f('0x7')],JSON[_0xbd8f('0x3c')](_0x353e34));var _0x753f0='';if(_0x353e34){if(_0x353e34['textCode']){_0x753f0=_0x353e34['textCode'];}else{for(var _0x44776c in _0x353e34){if(_0x353e34['hasOwnProperty'](_0x44776c)){_0x753f0+=_[_0xbd8f('0x3d')](_0x44776c)+':\x20'+_0x353e34[_0x44776c]+'\x0a';}}}}if(_0x2f014b){this[_0xbd8f('0x2')][_0xbd8f('0x2a')]();}else{this[_0xbd8f('0x3e')](_0xbd8f('0xe'),_0x753f0);this[_0xbd8f('0x3e')](_0xbd8f('0x2a'));}};module[_0xbd8f('0x3f')]=EmailImap;
\ No newline at end of file
+var _0x4819=['host','getHost','anonymous@xcally.com','openBox','handleOpenBox','emit','readUnseen','handleCloseBox','search','handleReadUnseen','fetch','handleFetchMessage','handleFetchError','handleFetchEnd','closeBox','body','handleMessageBody','attributes','handleMessageAttributes','handleSimpleParser','parser','email','stringify','textCode','upperFirst','util','imap','mailparser','simpleParser','iconv','Iconv','events','EventEmitter','./utils','../../../config/logger','INBOX','account','getAccount','once','handleReady','end','handleEnd','bind','error','handleError','inherits','prototype','connTimeout','authTimeout','service','user','password','port','tls','autotls','required','modernAuthentication','xoauth2','CloudProvider','data5'];(function(_0x146ee9,_0x19befe){var _0x60b23e=function(_0x2e249e){while(--_0x2e249e){_0x146ee9['push'](_0x146ee9['shift']());}};_0x60b23e(++_0x19befe);}(_0x4819,0xcd));var _0x9481=function(_0x2ba853,_0x45be){_0x2ba853=_0x2ba853-0x0;var _0xe21285=_0x4819[_0x2ba853];return _0xe21285;};'use strict';var _=require('lodash');var util=require(_0x9481('0x0'));var Imap=require(_0x9481('0x1'));var simpleParser=require(_0x9481('0x2'))[_0x9481('0x3')];var Iconv=require(_0x9481('0x4'))[_0x9481('0x5')];var EventEmitter=require(_0x9481('0x6'))[_0x9481('0x7')];var utils=require(_0x9481('0x8'));var logger=require(_0x9481('0x9'))('email');function EmailImap(_0x4d9e3a,_0x5def07){this['mailbox']=_0x9481('0xa');this[_0x9481('0xb')]=this[_0x9481('0xc')](_0x4d9e3a,_0x5def07);this[_0x9481('0x1')]=new Imap(this[_0x9481('0xb')]);this['imap'][_0x9481('0xd')]('ready',this[_0x9481('0xe')]['bind'](this));this[_0x9481('0x1')][_0x9481('0xd')](_0x9481('0xf'),this[_0x9481('0x10')][_0x9481('0x11')](this));this[_0x9481('0x1')]['on'](_0x9481('0x12'),this[_0x9481('0x13')][_0x9481('0x11')](this));this['imap']['connect']();}util[_0x9481('0x14')](EmailImap,EventEmitter);EmailImap[_0x9481('0x15')][_0x9481('0xc')]=function(_0x28fcb6,_0x3d23c2){var _0xc7a0b5={'connTimeout':_0x28fcb6[_0x9481('0x16')]?_0x28fcb6['connTimeout']*0x3e8:0x2710,'authTimeout':_0x28fcb6[_0x9481('0x17')]?_0x28fcb6[_0x9481('0x17')]*0x3e8:0x1388};if(_['isNil'](_0x28fcb6[_0x9481('0x18')])){if(_0x28fcb6['authentication']){_0xc7a0b5[_0x9481('0x19')]=_0x28fcb6[_0x9481('0x19')];_0xc7a0b5[_0x9481('0x1a')]=_0x28fcb6[_0x9481('0x1a')];}_0xc7a0b5['host']=_0x28fcb6['host'];_0xc7a0b5[_0x9481('0x1b')]=_0x28fcb6['port']||0x3e1;if(_0x28fcb6['tls']){_0xc7a0b5[_0x9481('0x1c')]=!![];}else{_0xc7a0b5[_0x9481('0x1c')]=![];_0xc7a0b5[_0x9481('0x1d')]=_0x9481('0x1e');}}else{if(_0x28fcb6[_0x9481('0x1f')]){_0xc7a0b5[_0x9481('0x20')]=utils['generateXOAuth2Token'](_0x28fcb6[_0x9481('0x21')][_0x9481('0x22')],_0x28fcb6[_0x9481('0x19')]);_0xc7a0b5[_0x9481('0x19')]=_0x28fcb6[_0x9481('0x19')];}else{_0xc7a0b5['user']=_0x28fcb6[_0x9481('0x19')];_0xc7a0b5[_0x9481('0x1a')]=_0x28fcb6['password'];}_0xc7a0b5[_0x9481('0x23')]=utils[_0x9481('0x24')](_0x28fcb6[_0x9481('0x18')]);_0xc7a0b5[_0x9481('0x1b')]=0x3e1;_0xc7a0b5[_0x9481('0x1c')]=!![];}_0xc7a0b5['email']=_0x3d23c2||_0x28fcb6[_0x9481('0x19')]||_0x9481('0x25');return _0xc7a0b5;};EmailImap['prototype']['handleReady']=function(){this[_0x9481('0x1')][_0x9481('0x26')](this['mailbox'],![],this[_0x9481('0x27')][_0x9481('0x11')](this));};EmailImap[_0x9481('0x15')][_0x9481('0x27')]=function(_0x5a1300,_0x14f03e){if(_0x5a1300){this[_0x9481('0x13')](_0x5a1300,!![]);}else{this[_0x9481('0x28')]('box',_0x14f03e);this[_0x9481('0x29')]();}};EmailImap['prototype'][_0x9481('0x2a')]=function(_0xe153ab){if(_0xe153ab){this[_0x9481('0x13')](_0xe153ab,!![]);}else{this[_0x9481('0x1')][_0x9481('0xf')]();}};EmailImap['prototype'][_0x9481('0x29')]=function(){this[_0x9481('0x1')][_0x9481('0x2b')](['UNSEEN'],this['handleReadUnseen'][_0x9481('0x11')](this));};EmailImap[_0x9481('0x15')][_0x9481('0x2c')]=function(_0x2b33f8,_0x5d9926){if(_0x2b33f8){this['handleError'](_0x2b33f8,!![]);}else{if(_0x5d9926['length']){try{var _0x29e6b6=this['imap'][_0x9481('0x2d')](_0x5d9926,{'bodies':'','markSeen':!![]});_0x29e6b6['on']('message',this[_0x9481('0x2e')][_0x9481('0x11')](this));_0x29e6b6[_0x9481('0xd')](_0x9481('0x12'),this[_0x9481('0x2f')]['bind'](this));_0x29e6b6[_0x9481('0xd')](_0x9481('0xf'),this[_0x9481('0x30')]['bind'](this));}catch(_0x30063f){logger[_0x9481('0x12')](_0x30063f);}}else{this[_0x9481('0x1')][_0x9481('0x31')](!![],this[_0x9481('0x2a')][_0x9481('0x11')](this));}}};EmailImap['prototype'][_0x9481('0x2e')]=function(_0x53af85){_0x53af85['on'](_0x9481('0x32'),this[_0x9481('0x33')][_0x9481('0x11')](this));_0x53af85[_0x9481('0xd')](_0x9481('0x34'),this[_0x9481('0x35')]['bind'](this));_0x53af85[_0x9481('0xd')](_0x9481('0xf'),this['handleMessageEnd']['bind'](this));};EmailImap[_0x9481('0x15')]['handleMessageBody']=function(_0x224b88){simpleParser(_0x224b88,{'Iconv':Iconv},this[_0x9481('0x36')][_0x9481('0x11')](this));};EmailImap[_0x9481('0x15')]['handleMessageAttributes']=function(){};EmailImap[_0x9481('0x15')]['handleMessageEnd']=function(){};EmailImap[_0x9481('0x15')]['handleSimpleParser']=function(_0x2ce972,_0x4d6a13){if(_0x2ce972){logger[_0x9481('0x12')](_0x2ce972);}else{var _0x22e916=this;utils[_0x9481('0x37')](this[_0x9481('0xb')],_0x4d6a13,function(_0x97dc3e){_0x22e916[_0x9481('0x28')](_0x9481('0x38'),_0x97dc3e);});}};EmailImap['prototype'][_0x9481('0x30')]=function(){this[_0x9481('0x1')][_0x9481('0x31')](!![],this[_0x9481('0x2a')][_0x9481('0x11')](this));};EmailImap[_0x9481('0x15')][_0x9481('0x2f')]=function(_0x4e081d){this[_0x9481('0x13')](_0x4e081d);this[_0x9481('0x1')]['closeBox'](!![],this[_0x9481('0x2a')][_0x9481('0x11')](this));};EmailImap[_0x9481('0x15')][_0x9481('0x10')]=function(){this[_0x9481('0x28')]('end');};EmailImap[_0x9481('0x15')]['handleError']=function(_0x23811a,_0xcc7f31){logger['error']('handleError',this[_0x9481('0xb')][_0x9481('0x38')],JSON[_0x9481('0x39')](_0x23811a));var _0x4c4caf='';if(_0x23811a){if(_0x23811a[_0x9481('0x3a')]){_0x4c4caf=_0x23811a[_0x9481('0x3a')];}else{for(var _0x5502ad in _0x23811a){if(_0x23811a['hasOwnProperty'](_0x5502ad)){_0x4c4caf+=_[_0x9481('0x3b')](_0x5502ad)+':\x20'+_0x23811a[_0x5502ad]+'\x0a';}}}}if(_0xcc7f31){this['imap'][_0x9481('0xf')]();}else{this[_0x9481('0x28')](_0x9481('0x12'),_0x4c4caf);this[_0x9481('0x28')](_0x9481('0xf'));}};module['exports']=EmailImap;
\ No newline at end of file