Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / services / email / lib / imap.js
index d9161f3..c20b74b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3363=['handleFetchError','body','handleMessageAttributes','handleMessageEnd','handleSimpleParser','parser','handleFetchEnd','closeBox','textCode','hasOwnProperty','upperFirst','exports','lodash','util','simpleParser','iconv','events','EventEmitter','./utils','email','mailbox','account','imap','bind','once','handleEnd','error','handleError','connect','inherits','prototype','getAccount','connTimeout','authTimeout','service','user','modernAuthentication','xoauth2','generateXOAuth2Token','CloudProvider','data5','password','authentication','anonymous@xcally.com','host','port','tls','autotls','required','handleReady','openBox','handleOpenBox','emit','box','handleCloseBox','end','readUnseen','search','UNSEEN','handleReadUnseen','fetch','message','handleFetchMessage'];(function(_0x316904,_0x1e8b77){var _0xfa9a21=function(_0x2b75ae){while(--_0x2b75ae){_0x316904['push'](_0x316904['shift']());}};_0xfa9a21(++_0x1e8b77);}(_0x3363,0x8a));var _0x3336=function(_0x538cbd,_0x48d4ef){_0x538cbd=_0x538cbd-0x0;var _0x676281=_0x3363[_0x538cbd];return _0x676281;};'use strict';var _=require(_0x3336('0x0'));var util=require(_0x3336('0x1'));var Imap=require('imap');var simpleParser=require('mailparser')[_0x3336('0x2')];var Iconv=require(_0x3336('0x3'))['Iconv'];var EventEmitter=require(_0x3336('0x4'))[_0x3336('0x5')];var utils=require(_0x3336('0x6'));var logger=require('../../../config/logger')(_0x3336('0x7'));function EmailImap(_0x134f3c,_0x57db5b){this[_0x3336('0x8')]=_0x134f3c['mailbox'];this[_0x3336('0x9')]=this['getAccount'](_0x134f3c,_0x57db5b);this[_0x3336('0xa')]=new Imap(this[_0x3336('0x9')]);this[_0x3336('0xa')]['once']('ready',this['handleReady'][_0x3336('0xb')](this));this['imap'][_0x3336('0xc')]('end',this[_0x3336('0xd')]['bind'](this));this['imap']['on'](_0x3336('0xe'),this[_0x3336('0xf')][_0x3336('0xb')](this));this['imap'][_0x3336('0x10')]();}util[_0x3336('0x11')](EmailImap,EventEmitter);EmailImap[_0x3336('0x12')][_0x3336('0x13')]=function(_0x2bd9e4,_0x576cf9){var _0x10fbeb={'connTimeout':_0x2bd9e4[_0x3336('0x14')]?_0x2bd9e4['connTimeout']*0x3e8:0x2710,'authTimeout':_0x2bd9e4[_0x3336('0x15')]?_0x2bd9e4[_0x3336('0x15')]*0x3e8:0x1388};if(_0x2bd9e4[_0x3336('0x16')]){_0x10fbeb[_0x3336('0x17')]=_0x2bd9e4[_0x3336('0x17')];if(_0x2bd9e4[_0x3336('0x18')]){_0x10fbeb[_0x3336('0x19')]=utils[_0x3336('0x1a')](_0x2bd9e4[_0x3336('0x1b')][_0x3336('0x1c')],_0x2bd9e4[_0x3336('0x17')]);}else{_0x10fbeb['password']=_0x2bd9e4[_0x3336('0x1d')];}}else{if(_0x2bd9e4[_0x3336('0x1e')]){_0x10fbeb['user']=_0x2bd9e4['user'];_0x10fbeb[_0x3336('0x1d')]=_0x2bd9e4[_0x3336('0x1d')];}}_0x10fbeb[_0x3336('0x7')]=_0x576cf9||_0x2bd9e4[_0x3336('0x17')]||_0x3336('0x1f');_0x10fbeb['host']=_0x2bd9e4[_0x3336('0x20')];_0x10fbeb['port']=_0x2bd9e4[_0x3336('0x21')]||0x3e1;if(_0x2bd9e4[_0x3336('0x22')]){_0x10fbeb[_0x3336('0x22')]=!![];}else{_0x10fbeb[_0x3336('0x22')]=![];_0x10fbeb[_0x3336('0x23')]=_0x3336('0x24');}return _0x10fbeb;};EmailImap['prototype'][_0x3336('0x25')]=function(){this[_0x3336('0xa')][_0x3336('0x26')](this[_0x3336('0x8')],![],this['handleOpenBox'][_0x3336('0xb')](this));};EmailImap['prototype'][_0x3336('0x27')]=function(_0x5b2e45,_0x8dacd6){if(_0x5b2e45){this['handleError'](_0x5b2e45,!![]);}else{this[_0x3336('0x28')](_0x3336('0x29'),_0x8dacd6);this['readUnseen']();}};EmailImap[_0x3336('0x12')][_0x3336('0x2a')]=function(_0x1ec82a){if(_0x1ec82a){this[_0x3336('0xf')](_0x1ec82a,!![]);}else{this['imap'][_0x3336('0x2b')]();}};EmailImap[_0x3336('0x12')][_0x3336('0x2c')]=function(){this[_0x3336('0xa')][_0x3336('0x2d')]([_0x3336('0x2e')],this['handleReadUnseen'][_0x3336('0xb')](this));};EmailImap['prototype'][_0x3336('0x2f')]=function(_0xf4103d,_0x27c970){if(_0xf4103d){this[_0x3336('0xf')](_0xf4103d,!![]);}else{if(_0x27c970['length']){try{var _0x2b8428=this[_0x3336('0xa')][_0x3336('0x30')](_0x27c970,{'bodies':'','markSeen':!![]});_0x2b8428['on'](_0x3336('0x31'),this[_0x3336('0x32')][_0x3336('0xb')](this));_0x2b8428['once']('error',this[_0x3336('0x33')][_0x3336('0xb')](this));_0x2b8428[_0x3336('0xc')](_0x3336('0x2b'),this['handleFetchEnd']['bind'](this));}catch(_0xe8048e){logger[_0x3336('0xe')](_0xe8048e);}}else{this[_0x3336('0xa')]['closeBox'](!![],this[_0x3336('0x2a')][_0x3336('0xb')](this));}}};EmailImap[_0x3336('0x12')]['handleFetchMessage']=function(_0x13c488){_0x13c488['on'](_0x3336('0x34'),this['handleMessageBody'][_0x3336('0xb')](this));_0x13c488[_0x3336('0xc')]('attributes',this[_0x3336('0x35')][_0x3336('0xb')](this));_0x13c488['once']('end',this[_0x3336('0x36')]['bind'](this));};EmailImap[_0x3336('0x12')]['handleMessageBody']=function(_0x42e687){simpleParser(_0x42e687,{'Iconv':Iconv},this[_0x3336('0x37')][_0x3336('0xb')](this));};EmailImap[_0x3336('0x12')][_0x3336('0x35')]=function(){};EmailImap['prototype'][_0x3336('0x36')]=function(){};EmailImap[_0x3336('0x12')][_0x3336('0x37')]=function(_0x7b948f,_0x3ba821){if(_0x7b948f){logger[_0x3336('0xe')](_0x7b948f);}else{var _0x25169b=this;utils[_0x3336('0x38')](this['account'],_0x3ba821,function(_0x20eae9){_0x25169b[_0x3336('0x28')]('email',_0x20eae9);});}};EmailImap[_0x3336('0x12')][_0x3336('0x39')]=function(){this[_0x3336('0xa')][_0x3336('0x3a')](!![],this['handleCloseBox'][_0x3336('0xb')](this));};EmailImap[_0x3336('0x12')][_0x3336('0x33')]=function(_0xd1920){this[_0x3336('0xf')](_0xd1920);this['imap'][_0x3336('0x3a')](!![],this[_0x3336('0x2a')][_0x3336('0xb')](this));};EmailImap[_0x3336('0x12')][_0x3336('0xd')]=function(){this['emit']('end');};EmailImap['prototype'][_0x3336('0xf')]=function(_0x35a415,_0x10e606){logger[_0x3336('0xe')](_0x3336('0xf'),this[_0x3336('0x9')][_0x3336('0x7')],JSON['stringify'](_0x35a415));var _0x440637='';if(_0x35a415){if(_0x35a415[_0x3336('0x3b')]){_0x440637=_0x35a415[_0x3336('0x3b')];}else{for(var _0x15bce8 in _0x35a415){if(_0x35a415[_0x3336('0x3c')](_0x15bce8)){_0x440637+=_[_0x3336('0x3d')](_0x15bce8)+':\x20'+_0x35a415[_0x15bce8]+'\x0a';}}}}if(_0x10e606){this['imap'][_0x3336('0x2b')]();}else{this[_0x3336('0x28')]('error',_0x440637);this[_0x3336('0x28')](_0x3336('0x2b'));}};module[_0x3336('0x3e')]=EmailImap;
\ No newline at end of file
+var _0xf4eb=['EventEmitter','./utils','email','mailbox','account','getAccount','once','handleReady','bind','end','error','inherits','prototype','connTimeout','authTimeout','service','user','modernAuthentication','CloudProvider','data5','password','authentication','anonymous@xcally.com','host','port','tls','autotls','required','handleOpenBox','handleError','emit','box','readUnseen','search','handleReadUnseen','message','handleFetchMessage','handleFetchError','handleFetchEnd','closeBox','body','handleMessageBody','attributes','handleMessageAttributes','handleSimpleParser','handleCloseBox','handleEnd','stringify','textCode','hasOwnProperty','upperFirst','lodash','imap','mailparser','Iconv','events'];(function(_0x47e9b7,_0x47f72c){var _0x506af3=function(_0xaff41b){while(--_0xaff41b){_0x47e9b7['push'](_0x47e9b7['shift']());}};_0x506af3(++_0x47f72c);}(_0xf4eb,0x1bb));var _0xbf4e=function(_0xb3401d,_0x5ede67){_0xb3401d=_0xb3401d-0x0;var _0xda36d5=_0xf4eb[_0xb3401d];return _0xda36d5;};'use strict';var _=require(_0xbf4e('0x0'));var util=require('util');var Imap=require(_0xbf4e('0x1'));var simpleParser=require(_0xbf4e('0x2'))['simpleParser'];var Iconv=require('iconv')[_0xbf4e('0x3')];var EventEmitter=require(_0xbf4e('0x4'))[_0xbf4e('0x5')];var utils=require(_0xbf4e('0x6'));var logger=require('../../../config/logger')(_0xbf4e('0x7'));function EmailImap(_0xaa2eb7,_0x558d72){this[_0xbf4e('0x8')]=_0xaa2eb7[_0xbf4e('0x8')];this[_0xbf4e('0x9')]=this[_0xbf4e('0xa')](_0xaa2eb7,_0x558d72);this[_0xbf4e('0x1')]=new Imap(this[_0xbf4e('0x9')]);this[_0xbf4e('0x1')][_0xbf4e('0xb')]('ready',this[_0xbf4e('0xc')][_0xbf4e('0xd')](this));this[_0xbf4e('0x1')][_0xbf4e('0xb')](_0xbf4e('0xe'),this['handleEnd'][_0xbf4e('0xd')](this));this['imap']['on'](_0xbf4e('0xf'),this['handleError']['bind'](this));this[_0xbf4e('0x1')]['connect']();}util[_0xbf4e('0x10')](EmailImap,EventEmitter);EmailImap[_0xbf4e('0x11')]['getAccount']=function(_0x2b6e61,_0x2e144d){var _0x551d39={'connTimeout':_0x2b6e61[_0xbf4e('0x12')]?_0x2b6e61[_0xbf4e('0x12')]*0x3e8:0x2710,'authTimeout':_0x2b6e61[_0xbf4e('0x13')]?_0x2b6e61[_0xbf4e('0x13')]*0x3e8:0x1388};if(_0x2b6e61[_0xbf4e('0x14')]){_0x551d39['user']=_0x2b6e61[_0xbf4e('0x15')];if(_0x2b6e61[_0xbf4e('0x16')]){_0x551d39['xoauth2']=utils['generateXOAuth2Token'](_0x2b6e61[_0xbf4e('0x17')][_0xbf4e('0x18')],_0x2b6e61[_0xbf4e('0x15')]);}else{_0x551d39[_0xbf4e('0x19')]=_0x2b6e61[_0xbf4e('0x19')];}}else{if(_0x2b6e61[_0xbf4e('0x1a')]){_0x551d39[_0xbf4e('0x15')]=_0x2b6e61['user'];_0x551d39[_0xbf4e('0x19')]=_0x2b6e61['password'];}}_0x551d39[_0xbf4e('0x7')]=_0x2e144d||_0x2b6e61[_0xbf4e('0x15')]||_0xbf4e('0x1b');_0x551d39[_0xbf4e('0x1c')]=_0x2b6e61['host'];_0x551d39['port']=_0x2b6e61[_0xbf4e('0x1d')]||0x3e1;if(_0x2b6e61[_0xbf4e('0x1e')]){_0x551d39['tls']=!![];}else{_0x551d39['tls']=![];_0x551d39[_0xbf4e('0x1f')]=_0xbf4e('0x20');}return _0x551d39;};EmailImap[_0xbf4e('0x11')][_0xbf4e('0xc')]=function(){this[_0xbf4e('0x1')]['openBox'](this[_0xbf4e('0x8')],![],this[_0xbf4e('0x21')][_0xbf4e('0xd')](this));};EmailImap[_0xbf4e('0x11')]['handleOpenBox']=function(_0x49b0f4,_0x27ac85){if(_0x49b0f4){this[_0xbf4e('0x22')](_0x49b0f4,!![]);}else{this[_0xbf4e('0x23')](_0xbf4e('0x24'),_0x27ac85);this['readUnseen']();}};EmailImap['prototype']['handleCloseBox']=function(_0x255166){if(_0x255166){this[_0xbf4e('0x22')](_0x255166,!![]);}else{this['imap'][_0xbf4e('0xe')]();}};EmailImap[_0xbf4e('0x11')][_0xbf4e('0x25')]=function(){this[_0xbf4e('0x1')][_0xbf4e('0x26')](['UNSEEN'],this['handleReadUnseen']['bind'](this));};EmailImap[_0xbf4e('0x11')][_0xbf4e('0x27')]=function(_0x486096,_0x5a7522){if(_0x486096){this['handleError'](_0x486096,!![]);}else{if(_0x5a7522['length']){try{var _0x2fd09a=this['imap']['fetch'](_0x5a7522,{'bodies':'','markSeen':!![]});_0x2fd09a['on'](_0xbf4e('0x28'),this[_0xbf4e('0x29')]['bind'](this));_0x2fd09a[_0xbf4e('0xb')](_0xbf4e('0xf'),this[_0xbf4e('0x2a')][_0xbf4e('0xd')](this));_0x2fd09a[_0xbf4e('0xb')]('end',this[_0xbf4e('0x2b')][_0xbf4e('0xd')](this));}catch(_0x44f962){logger[_0xbf4e('0xf')](_0x44f962);}}else{this[_0xbf4e('0x1')][_0xbf4e('0x2c')](!![],this['handleCloseBox'][_0xbf4e('0xd')](this));}}};EmailImap[_0xbf4e('0x11')][_0xbf4e('0x29')]=function(_0x4c7f99){_0x4c7f99['on'](_0xbf4e('0x2d'),this[_0xbf4e('0x2e')][_0xbf4e('0xd')](this));_0x4c7f99[_0xbf4e('0xb')](_0xbf4e('0x2f'),this[_0xbf4e('0x30')]['bind'](this));_0x4c7f99[_0xbf4e('0xb')](_0xbf4e('0xe'),this['handleMessageEnd']['bind'](this));};EmailImap['prototype'][_0xbf4e('0x2e')]=function(_0x2d6eef){simpleParser(_0x2d6eef,{'Iconv':Iconv},this['handleSimpleParser'][_0xbf4e('0xd')](this));};EmailImap['prototype'][_0xbf4e('0x30')]=function(){};EmailImap[_0xbf4e('0x11')]['handleMessageEnd']=function(){};EmailImap[_0xbf4e('0x11')][_0xbf4e('0x31')]=function(_0x2e98be,_0x2f052d){if(_0x2e98be){logger[_0xbf4e('0xf')](_0x2e98be);}else{var _0x3eee19=this;utils['parser'](this[_0xbf4e('0x9')],_0x2f052d,function(_0x200a91){_0x3eee19['emit'](_0xbf4e('0x7'),_0x200a91);});}};EmailImap[_0xbf4e('0x11')]['handleFetchEnd']=function(){this[_0xbf4e('0x1')][_0xbf4e('0x2c')](!![],this[_0xbf4e('0x32')][_0xbf4e('0xd')](this));};EmailImap['prototype'][_0xbf4e('0x2a')]=function(_0x1ccf36){this[_0xbf4e('0x22')](_0x1ccf36);this[_0xbf4e('0x1')][_0xbf4e('0x2c')](!![],this[_0xbf4e('0x32')]['bind'](this));};EmailImap[_0xbf4e('0x11')][_0xbf4e('0x33')]=function(){this[_0xbf4e('0x23')](_0xbf4e('0xe'));};EmailImap[_0xbf4e('0x11')]['handleError']=function(_0x33e0c0,_0x57602f){logger[_0xbf4e('0xf')](_0xbf4e('0x22'),this[_0xbf4e('0x9')][_0xbf4e('0x7')],JSON[_0xbf4e('0x34')](_0x33e0c0));var _0x8b79fe='';if(_0x33e0c0){if(_0x33e0c0[_0xbf4e('0x35')]){_0x8b79fe=_0x33e0c0['textCode'];}else{for(var _0x4c2c36 in _0x33e0c0){if(_0x33e0c0[_0xbf4e('0x36')](_0x4c2c36)){_0x8b79fe+=_[_0xbf4e('0x37')](_0x4c2c36)+':\x20'+_0x33e0c0[_0x4c2c36]+'\x0a';}}}}if(_0x57602f){this[_0xbf4e('0x1')][_0xbf4e('0xe')]();}else{this['emit'](_0xbf4e('0xf'),_0x8b79fe);this[_0xbf4e('0x23')]('end');}};module['exports']=EmailImap;
\ No newline at end of file