Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / services / email / lib / imap.js
index 6305494..0d20cd9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8039=['autotls','required','prototype','handleOpenBox','emit','box','handleCloseBox','readUnseen','search','UNSEEN','handleReadUnseen','fetch','handleFetchMessage','handleFetchError','handleFetchEnd','closeBox','body','handleMessageBody','attributes','handleMessageAttributes','handleSimpleParser','parser','textCode','exports','util','simpleParser','iconv','Iconv','events','EventEmitter','./utils','../../../config/logger','email','mailbox','getAccount','account','imap','once','handleReady','bind','end','handleEnd','error','handleError','connect','inherits','connTimeout','authTimeout','service','user','modernAuthentication','xoauth2','generateXOAuth2Token','CloudProvider','data5','password','authentication','host','port','tls'];(function(_0x3d24ca,_0x2110e1){var _0x3479cf=function(_0x433111){while(--_0x433111){_0x3d24ca['push'](_0x3d24ca['shift']());}};_0x3479cf(++_0x2110e1);}(_0x8039,0xcc));var _0x9803=function(_0x245afe,_0x319cde){_0x245afe=_0x245afe-0x0;var _0x4eefde=_0x8039[_0x245afe];return _0x4eefde;};'use strict';var _=require('lodash');var util=require(_0x9803('0x0'));var Imap=require('imap');var simpleParser=require('mailparser')[_0x9803('0x1')];var Iconv=require(_0x9803('0x2'))[_0x9803('0x3')];var EventEmitter=require(_0x9803('0x4'))[_0x9803('0x5')];var utils=require(_0x9803('0x6'));var logger=require(_0x9803('0x7'))(_0x9803('0x8'));function EmailImap(_0x67173b,_0x1ec459){this[_0x9803('0x9')]=_0x67173b['mailbox'];this['account']=this[_0x9803('0xa')](_0x67173b,_0x1ec459);this['imap']=new Imap(this[_0x9803('0xb')]);this[_0x9803('0xc')][_0x9803('0xd')]('ready',this[_0x9803('0xe')][_0x9803('0xf')](this));this[_0x9803('0xc')][_0x9803('0xd')](_0x9803('0x10'),this[_0x9803('0x11')][_0x9803('0xf')](this));this[_0x9803('0xc')]['on'](_0x9803('0x12'),this[_0x9803('0x13')][_0x9803('0xf')](this));this[_0x9803('0xc')][_0x9803('0x14')]();}util[_0x9803('0x15')](EmailImap,EventEmitter);EmailImap['prototype'][_0x9803('0xa')]=function(_0x3e45f7,_0x17a9ff){var _0x15dd9e={'connTimeout':_0x3e45f7[_0x9803('0x16')]?_0x3e45f7[_0x9803('0x16')]*0x3e8:0x2710,'authTimeout':_0x3e45f7[_0x9803('0x17')]?_0x3e45f7[_0x9803('0x17')]*0x3e8:0x1388};if(_0x3e45f7[_0x9803('0x18')]){_0x15dd9e['user']=_0x3e45f7[_0x9803('0x19')];if(_0x3e45f7[_0x9803('0x1a')]){_0x15dd9e[_0x9803('0x1b')]=utils[_0x9803('0x1c')](_0x3e45f7[_0x9803('0x1d')][_0x9803('0x1e')],_0x3e45f7[_0x9803('0x19')]);}else{_0x15dd9e[_0x9803('0x1f')]=_0x3e45f7[_0x9803('0x1f')];}}else{if(_0x3e45f7[_0x9803('0x20')]){_0x15dd9e[_0x9803('0x19')]=_0x3e45f7[_0x9803('0x19')];_0x15dd9e[_0x9803('0x1f')]=_0x3e45f7['password'];}}_0x15dd9e[_0x9803('0x8')]=_0x17a9ff||_0x3e45f7[_0x9803('0x19')]||'anonymous@xcally.com';_0x15dd9e[_0x9803('0x21')]=_0x3e45f7[_0x9803('0x21')];_0x15dd9e[_0x9803('0x22')]=_0x3e45f7[_0x9803('0x22')]||0x3e1;if(_0x3e45f7[_0x9803('0x23')]){_0x15dd9e['tls']=!![];}else{_0x15dd9e[_0x9803('0x23')]=![];_0x15dd9e[_0x9803('0x24')]=_0x9803('0x25');}return _0x15dd9e;};EmailImap[_0x9803('0x26')][_0x9803('0xe')]=function(){this[_0x9803('0xc')]['openBox'](this[_0x9803('0x9')],![],this[_0x9803('0x27')][_0x9803('0xf')](this));};EmailImap[_0x9803('0x26')]['handleOpenBox']=function(_0x2db236,_0x36722e){if(_0x2db236){this['handleError'](_0x2db236,!![]);}else{this[_0x9803('0x28')](_0x9803('0x29'),_0x36722e);this['readUnseen']();}};EmailImap[_0x9803('0x26')][_0x9803('0x2a')]=function(_0x2b25dd){if(_0x2b25dd){this[_0x9803('0x13')](_0x2b25dd,!![]);}else{this[_0x9803('0xc')]['end']();}};EmailImap['prototype'][_0x9803('0x2b')]=function(){this['imap'][_0x9803('0x2c')]([_0x9803('0x2d')],this[_0x9803('0x2e')][_0x9803('0xf')](this));};EmailImap[_0x9803('0x26')][_0x9803('0x2e')]=function(_0x46603d,_0xe72083){if(_0x46603d){this[_0x9803('0x13')](_0x46603d,!![]);}else{if(_0xe72083['length']){try{var _0x256d21=this[_0x9803('0xc')][_0x9803('0x2f')](_0xe72083,{'bodies':'','markSeen':!![]});_0x256d21['on']('message',this[_0x9803('0x30')][_0x9803('0xf')](this));_0x256d21[_0x9803('0xd')]('error',this[_0x9803('0x31')]['bind'](this));_0x256d21['once'](_0x9803('0x10'),this[_0x9803('0x32')][_0x9803('0xf')](this));}catch(_0x1e0598){logger['error'](_0x1e0598);}}else{this['imap'][_0x9803('0x33')](!![],this[_0x9803('0x2a')][_0x9803('0xf')](this));}}};EmailImap[_0x9803('0x26')][_0x9803('0x30')]=function(_0x37be93){_0x37be93['on'](_0x9803('0x34'),this[_0x9803('0x35')][_0x9803('0xf')](this));_0x37be93[_0x9803('0xd')](_0x9803('0x36'),this[_0x9803('0x37')]['bind'](this));_0x37be93['once'](_0x9803('0x10'),this['handleMessageEnd'][_0x9803('0xf')](this));};EmailImap[_0x9803('0x26')][_0x9803('0x35')]=function(_0xbca156){simpleParser(_0xbca156,{'Iconv':Iconv},this[_0x9803('0x38')][_0x9803('0xf')](this));};EmailImap['prototype'][_0x9803('0x37')]=function(){};EmailImap[_0x9803('0x26')]['handleMessageEnd']=function(){};EmailImap['prototype'][_0x9803('0x38')]=function(_0x546629,_0x24f96a){if(_0x546629){logger[_0x9803('0x12')](_0x546629);}else{var _0x1c1944=this;utils[_0x9803('0x39')](this[_0x9803('0xb')],_0x24f96a,function(_0x5f09da){_0x1c1944[_0x9803('0x28')](_0x9803('0x8'),_0x5f09da);});}};EmailImap[_0x9803('0x26')][_0x9803('0x32')]=function(){this['imap']['closeBox'](!![],this[_0x9803('0x2a')]['bind'](this));};EmailImap[_0x9803('0x26')][_0x9803('0x31')]=function(_0x2f5863){this['handleError'](_0x2f5863);this[_0x9803('0xc')][_0x9803('0x33')](!![],this[_0x9803('0x2a')][_0x9803('0xf')](this));};EmailImap[_0x9803('0x26')][_0x9803('0x11')]=function(){this[_0x9803('0x28')](_0x9803('0x10'));};EmailImap[_0x9803('0x26')]['handleError']=function(_0x41f3c3,_0x5e0736){logger[_0x9803('0x12')]('handleError',this[_0x9803('0xb')][_0x9803('0x8')],JSON['stringify'](_0x41f3c3));var _0x936b77='';if(_0x41f3c3){if(_0x41f3c3[_0x9803('0x3a')]){_0x936b77=_0x41f3c3[_0x9803('0x3a')];}else{for(var _0x494ef3 in _0x41f3c3){if(_0x41f3c3['hasOwnProperty'](_0x494ef3)){_0x936b77+=_['upperFirst'](_0x494ef3)+':\x20'+_0x41f3c3[_0x494ef3]+'\x0a';}}}}if(_0x5e0736){this['imap']['end']();}else{this[_0x9803('0x28')]('error',_0x936b77);this[_0x9803('0x28')](_0x9803('0x10'));}};module[_0x9803('0x3b')]=EmailImap;
\ No newline at end of file
+var _0x6cd7=['account','once','handleReady','bind','end','handleEnd','error','handleError','connect','inherits','prototype','connTimeout','authTimeout','service','modernAuthentication','generateXOAuth2Token','CloudProvider','data5','password','authentication','user','anonymous@xcally.com','host','port','tls','openBox','handleOpenBox','emit','box','readUnseen','handleCloseBox','search','UNSEEN','handleReadUnseen','length','fetch','handleFetchMessage','handleFetchError','handleFetchEnd','closeBox','body','handleMessageBody','attributes','handleMessageAttributes','handleMessageEnd','handleSimpleParser','parser','textCode','hasOwnProperty','upperFirst','exports','lodash','imap','mailparser','simpleParser','iconv','Iconv','events','EventEmitter','email','mailbox'];(function(_0x3f941c,_0x121c43){var _0x3740bc=function(_0x50dd2c){while(--_0x50dd2c){_0x3f941c['push'](_0x3f941c['shift']());}};_0x3740bc(++_0x121c43);}(_0x6cd7,0x1de));var _0x76cd=function(_0x35e9ce,_0x4ebb8d){_0x35e9ce=_0x35e9ce-0x0;var _0x32e808=_0x6cd7[_0x35e9ce];return _0x32e808;};'use strict';var _=require(_0x76cd('0x0'));var util=require('util');var Imap=require(_0x76cd('0x1'));var simpleParser=require(_0x76cd('0x2'))[_0x76cd('0x3')];var Iconv=require(_0x76cd('0x4'))[_0x76cd('0x5')];var EventEmitter=require(_0x76cd('0x6'))[_0x76cd('0x7')];var utils=require('./utils');var logger=require('../../../config/logger')(_0x76cd('0x8'));function EmailImap(_0x2b2548,_0x52e756){this[_0x76cd('0x9')]=_0x2b2548[_0x76cd('0x9')];this[_0x76cd('0xa')]=this['getAccount'](_0x2b2548,_0x52e756);this[_0x76cd('0x1')]=new Imap(this[_0x76cd('0xa')]);this[_0x76cd('0x1')][_0x76cd('0xb')]('ready',this[_0x76cd('0xc')][_0x76cd('0xd')](this));this[_0x76cd('0x1')][_0x76cd('0xb')](_0x76cd('0xe'),this[_0x76cd('0xf')]['bind'](this));this[_0x76cd('0x1')]['on'](_0x76cd('0x10'),this[_0x76cd('0x11')][_0x76cd('0xd')](this));this['imap'][_0x76cd('0x12')]();}util[_0x76cd('0x13')](EmailImap,EventEmitter);EmailImap[_0x76cd('0x14')]['getAccount']=function(_0x4d6b8c,_0x4643){var _0xc98880={'connTimeout':_0x4d6b8c[_0x76cd('0x15')]?_0x4d6b8c['connTimeout']*0x3e8:0x2710,'authTimeout':_0x4d6b8c[_0x76cd('0x16')]?_0x4d6b8c['authTimeout']*0x3e8:0x1388};if(_0x4d6b8c[_0x76cd('0x17')]){_0xc98880['user']=_0x4d6b8c['user'];if(_0x4d6b8c[_0x76cd('0x18')]){_0xc98880['xoauth2']=utils[_0x76cd('0x19')](_0x4d6b8c[_0x76cd('0x1a')][_0x76cd('0x1b')],_0x4d6b8c['user']);}else{_0xc98880[_0x76cd('0x1c')]=_0x4d6b8c[_0x76cd('0x1c')];}}else{if(_0x4d6b8c[_0x76cd('0x1d')]){_0xc98880[_0x76cd('0x1e')]=_0x4d6b8c[_0x76cd('0x1e')];_0xc98880[_0x76cd('0x1c')]=_0x4d6b8c['password'];}}_0xc98880[_0x76cd('0x8')]=_0x4643||_0x4d6b8c[_0x76cd('0x1e')]||_0x76cd('0x1f');_0xc98880['host']=_0x4d6b8c[_0x76cd('0x20')];_0xc98880[_0x76cd('0x21')]=_0x4d6b8c[_0x76cd('0x21')]||0x3e1;if(_0x4d6b8c['tls']){_0xc98880[_0x76cd('0x22')]=!![];}else{_0xc98880[_0x76cd('0x22')]=![];_0xc98880['autotls']='required';}return _0xc98880;};EmailImap[_0x76cd('0x14')][_0x76cd('0xc')]=function(){this['imap'][_0x76cd('0x23')](this[_0x76cd('0x9')],![],this[_0x76cd('0x24')][_0x76cd('0xd')](this));};EmailImap[_0x76cd('0x14')][_0x76cd('0x24')]=function(_0x783ce,_0x512a76){if(_0x783ce){this[_0x76cd('0x11')](_0x783ce,!![]);}else{this[_0x76cd('0x25')](_0x76cd('0x26'),_0x512a76);this[_0x76cd('0x27')]();}};EmailImap[_0x76cd('0x14')][_0x76cd('0x28')]=function(_0x227067){if(_0x227067){this[_0x76cd('0x11')](_0x227067,!![]);}else{this[_0x76cd('0x1')]['end']();}};EmailImap[_0x76cd('0x14')][_0x76cd('0x27')]=function(){this[_0x76cd('0x1')][_0x76cd('0x29')]([_0x76cd('0x2a')],this[_0x76cd('0x2b')][_0x76cd('0xd')](this));};EmailImap['prototype'][_0x76cd('0x2b')]=function(_0xd6c545,_0x51cd01){if(_0xd6c545){this[_0x76cd('0x11')](_0xd6c545,!![]);}else{if(_0x51cd01[_0x76cd('0x2c')]){try{var _0x4e6b92=this[_0x76cd('0x1')][_0x76cd('0x2d')](_0x51cd01,{'bodies':'','markSeen':!![]});_0x4e6b92['on']('message',this[_0x76cd('0x2e')][_0x76cd('0xd')](this));_0x4e6b92[_0x76cd('0xb')](_0x76cd('0x10'),this[_0x76cd('0x2f')][_0x76cd('0xd')](this));_0x4e6b92[_0x76cd('0xb')](_0x76cd('0xe'),this[_0x76cd('0x30')][_0x76cd('0xd')](this));}catch(_0x219631){logger['error'](_0x219631);}}else{this[_0x76cd('0x1')][_0x76cd('0x31')](!![],this[_0x76cd('0x28')][_0x76cd('0xd')](this));}}};EmailImap['prototype'][_0x76cd('0x2e')]=function(_0x461008){_0x461008['on'](_0x76cd('0x32'),this[_0x76cd('0x33')][_0x76cd('0xd')](this));_0x461008[_0x76cd('0xb')](_0x76cd('0x34'),this[_0x76cd('0x35')][_0x76cd('0xd')](this));_0x461008[_0x76cd('0xb')](_0x76cd('0xe'),this[_0x76cd('0x36')][_0x76cd('0xd')](this));};EmailImap[_0x76cd('0x14')][_0x76cd('0x33')]=function(_0x306602){simpleParser(_0x306602,{'Iconv':Iconv},this['handleSimpleParser'][_0x76cd('0xd')](this));};EmailImap[_0x76cd('0x14')]['handleMessageAttributes']=function(){};EmailImap[_0x76cd('0x14')][_0x76cd('0x36')]=function(){};EmailImap[_0x76cd('0x14')][_0x76cd('0x37')]=function(_0x25fc3d,_0x6ac822){if(_0x25fc3d){logger['error'](_0x25fc3d);}else{var _0xdfdfe9=this;utils[_0x76cd('0x38')](this[_0x76cd('0xa')],_0x6ac822,function(_0xb0b176){_0xdfdfe9['emit'](_0x76cd('0x8'),_0xb0b176);});}};EmailImap['prototype'][_0x76cd('0x30')]=function(){this[_0x76cd('0x1')][_0x76cd('0x31')](!![],this[_0x76cd('0x28')][_0x76cd('0xd')](this));};EmailImap[_0x76cd('0x14')][_0x76cd('0x2f')]=function(_0x38af37){this[_0x76cd('0x11')](_0x38af37);this[_0x76cd('0x1')][_0x76cd('0x31')](!![],this[_0x76cd('0x28')][_0x76cd('0xd')](this));};EmailImap[_0x76cd('0x14')][_0x76cd('0xf')]=function(){this[_0x76cd('0x25')]('end');};EmailImap[_0x76cd('0x14')]['handleError']=function(_0xc5b424,_0x384e67){logger[_0x76cd('0x10')](_0x76cd('0x11'),this[_0x76cd('0xa')]['email'],JSON['stringify'](_0xc5b424));var _0x5616ab='';if(_0xc5b424){if(_0xc5b424['textCode']){_0x5616ab=_0xc5b424[_0x76cd('0x39')];}else{for(var _0xfb0b56 in _0xc5b424){if(_0xc5b424[_0x76cd('0x3a')](_0xfb0b56)){_0x5616ab+=_[_0x76cd('0x3b')](_0xfb0b56)+':\x20'+_0xc5b424[_0xfb0b56]+'\x0a';}}}}if(_0x384e67){this[_0x76cd('0x1')]['end']();}else{this[_0x76cd('0x25')](_0x76cd('0x10'),_0x5616ab);this[_0x76cd('0x25')](_0x76cd('0xe'));}};module[_0x76cd('0x3c')]=EmailImap;
\ No newline at end of file