Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / services / email / lib / imap.js
index acc32d8..ccf2f77 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe0d5=['util','imap','iconv','Iconv','events','EventEmitter','./utils','../../../config/logger','email','mailbox','account','getAccount','once','handleReady','bind','handleEnd','error','handleError','connect','prototype','connTimeout','authTimeout','user','modernAuthentication','xoauth2','CloudProvider','data5','password','anonymous@xcally.com','host','tls','openBox','handleOpenBox','box','readUnseen','handleCloseBox','end','search','UNSEEN','handleReadUnseen','length','fetch','slice','message','handleFetchMessage','handleFetchError','body','handleMessageBody','handleMessageAttributes','handleMessageEnd','handleSimpleParser','parser','emit','handleFetchEnd','closeBox','stringify','textCode','hasOwnProperty','exports','lodash'];(function(_0x2788b2,_0x4e735c){var _0xbca93f=function(_0x4dccf8){while(--_0x4dccf8){_0x2788b2['push'](_0x2788b2['shift']());}};_0xbca93f(++_0x4e735c);}(_0xe0d5,0xb3));var _0x5e0d=function(_0x23d3dd,_0x3be1be){_0x23d3dd=_0x23d3dd-0x0;var _0x872358=_0xe0d5[_0x23d3dd];return _0x872358;};'use strict';var _=require(_0x5e0d('0x0'));var util=require(_0x5e0d('0x1'));var Imap=require(_0x5e0d('0x2'));var simpleParser=require('mailparser')['simpleParser'];var Iconv=require(_0x5e0d('0x3'))[_0x5e0d('0x4')];var EventEmitter=require(_0x5e0d('0x5'))[_0x5e0d('0x6')];var utils=require(_0x5e0d('0x7'));var logger=require(_0x5e0d('0x8'))(_0x5e0d('0x9'));function EmailImap(_0x33e044,_0x4cc05c){this['mailbox']=_0x33e044[_0x5e0d('0xa')];this[_0x5e0d('0xb')]=this[_0x5e0d('0xc')](_0x33e044,_0x4cc05c);this[_0x5e0d('0x2')]=new Imap(this[_0x5e0d('0xb')]);this[_0x5e0d('0x2')][_0x5e0d('0xd')]('ready',this[_0x5e0d('0xe')][_0x5e0d('0xf')](this));this[_0x5e0d('0x2')][_0x5e0d('0xd')]('end',this[_0x5e0d('0x10')][_0x5e0d('0xf')](this));this[_0x5e0d('0x2')]['on'](_0x5e0d('0x11'),this[_0x5e0d('0x12')][_0x5e0d('0xf')](this));this[_0x5e0d('0x2')][_0x5e0d('0x13')]();}util['inherits'](EmailImap,EventEmitter);EmailImap[_0x5e0d('0x14')][_0x5e0d('0xc')]=function(_0x6db885,_0x27f68b){var _0x3d1d14={'connTimeout':_0x6db885['connTimeout']?_0x6db885[_0x5e0d('0x15')]*0x3e8:0x2710,'authTimeout':_0x6db885['authTimeout']?_0x6db885[_0x5e0d('0x16')]*0x3e8:0x1388};if(_0x6db885['service']){_0x3d1d14[_0x5e0d('0x17')]=_0x6db885[_0x5e0d('0x17')];if(_0x6db885[_0x5e0d('0x18')]){_0x3d1d14[_0x5e0d('0x19')]=utils['generateXOAuth2Token'](_0x6db885[_0x5e0d('0x1a')][_0x5e0d('0x1b')],_0x6db885['user']);}else{_0x3d1d14[_0x5e0d('0x1c')]=_0x6db885[_0x5e0d('0x1c')];}}else{if(_0x6db885['authentication']){_0x3d1d14[_0x5e0d('0x17')]=_0x6db885[_0x5e0d('0x17')];_0x3d1d14[_0x5e0d('0x1c')]=_0x6db885['password'];}}_0x3d1d14[_0x5e0d('0x9')]=_0x27f68b||_0x6db885[_0x5e0d('0x17')]||_0x5e0d('0x1d');_0x3d1d14[_0x5e0d('0x1e')]=_0x6db885['host'];_0x3d1d14['port']=_0x6db885['port']||0x3e1;if(_0x6db885[_0x5e0d('0x1f')]){_0x3d1d14['tls']=!![];}else{_0x3d1d14[_0x5e0d('0x1f')]=![];_0x3d1d14['autotls']='required';}return _0x3d1d14;};EmailImap[_0x5e0d('0x14')][_0x5e0d('0xe')]=function(){this[_0x5e0d('0x2')][_0x5e0d('0x20')](this['mailbox'],![],this[_0x5e0d('0x21')][_0x5e0d('0xf')](this));};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x21')]=function(_0x1daebb,_0x159bd7){if(_0x1daebb){this[_0x5e0d('0x12')](_0x1daebb,!![]);}else{this['emit'](_0x5e0d('0x22'),_0x159bd7);this[_0x5e0d('0x23')]();}};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x24')]=function(_0x30e96a){if(_0x30e96a){this[_0x5e0d('0x12')](_0x30e96a,!![]);}else{this['imap'][_0x5e0d('0x25')]();}};EmailImap[_0x5e0d('0x14')]['readUnseen']=function(){this[_0x5e0d('0x2')][_0x5e0d('0x26')]([_0x5e0d('0x27')],this['handleReadUnseen'][_0x5e0d('0xf')](this));};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x28')]=function(_0x129942,_0x3d33f8){if(_0x129942){this[_0x5e0d('0x12')](_0x129942,!![]);}else{if(_0x3d33f8[_0x5e0d('0x29')]){try{var _0x10f94c=this[_0x5e0d('0x2')][_0x5e0d('0x2a')](_0x3d33f8[_0x5e0d('0x2b')](0x0,0xa),{'bodies':'','markSeen':!![]});_0x10f94c['on'](_0x5e0d('0x2c'),this[_0x5e0d('0x2d')][_0x5e0d('0xf')](this));_0x10f94c[_0x5e0d('0xd')](_0x5e0d('0x11'),this[_0x5e0d('0x2e')]['bind'](this));_0x10f94c[_0x5e0d('0xd')](_0x5e0d('0x25'),this['handleFetchEnd'][_0x5e0d('0xf')](this));}catch(_0x3ae409){logger['error'](_0x3ae409);}}else{this[_0x5e0d('0x2')]['closeBox'](!![],this['handleCloseBox'][_0x5e0d('0xf')](this));}}};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x2d')]=function(_0x5a879b){_0x5a879b['on'](_0x5e0d('0x2f'),this[_0x5e0d('0x30')][_0x5e0d('0xf')](this));_0x5a879b[_0x5e0d('0xd')]('attributes',this[_0x5e0d('0x31')][_0x5e0d('0xf')](this));_0x5a879b['once'](_0x5e0d('0x25'),this[_0x5e0d('0x32')][_0x5e0d('0xf')](this));};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x30')]=function(_0x415b72){simpleParser(_0x415b72,{'Iconv':Iconv},this['handleSimpleParser']['bind'](this));};EmailImap['prototype'][_0x5e0d('0x31')]=function(){};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x32')]=function(){};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x33')]=function(_0x46d2d3,_0x47dfa8){if(_0x46d2d3){logger[_0x5e0d('0x11')](_0x46d2d3);}else{var _0x5922fe=this;utils[_0x5e0d('0x34')](this[_0x5e0d('0xb')],_0x47dfa8,function(_0x292d57){_0x5922fe[_0x5e0d('0x35')](_0x5e0d('0x9'),_0x292d57);});}};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x36')]=function(){this[_0x5e0d('0x2')][_0x5e0d('0x37')](!![],this['handleCloseBox'][_0x5e0d('0xf')](this));};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x2e')]=function(_0x4a8dd6){this[_0x5e0d('0x12')](_0x4a8dd6);this[_0x5e0d('0x2')]['closeBox'](!![],this[_0x5e0d('0x24')][_0x5e0d('0xf')](this));};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x10')]=function(){this['emit'](_0x5e0d('0x25'));};EmailImap[_0x5e0d('0x14')][_0x5e0d('0x12')]=function(_0x3fcf4b,_0x24e581){logger[_0x5e0d('0x11')](_0x5e0d('0x12'),this['account'][_0x5e0d('0x9')],JSON[_0x5e0d('0x38')](_0x3fcf4b));var _0x225839='';if(_0x3fcf4b){if(_0x3fcf4b[_0x5e0d('0x39')]){_0x225839=_0x3fcf4b['textCode'];}else{for(var _0x32af66 in _0x3fcf4b){if(_0x3fcf4b[_0x5e0d('0x3a')](_0x32af66)){_0x225839+=_['upperFirst'](_0x32af66)+':\x20'+_0x3fcf4b[_0x32af66]+'\x0a';}}}}if(_0x24e581){this[_0x5e0d('0x2')][_0x5e0d('0x25')]();}else{this['emit'](_0x5e0d('0x11'),_0x225839);this[_0x5e0d('0x35')](_0x5e0d('0x25'));}};module[_0x5e0d('0x3b')]=EmailImap;
\ No newline at end of file
+var _0x2aa8=['parser','stringify','textCode','hasOwnProperty','exports','imap','mailparser','simpleParser','Iconv','events','EventEmitter','../../../config/logger','mailbox','account','once','handleReady','handleEnd','error','handleError','bind','connect','inherits','prototype','getAccount','connTimeout','authTimeout','service','user','modernAuthentication','data5','password','authentication','email','anonymous@xcally.com','host','port','tls','autotls','required','openBox','handleOpenBox','emit','box','readUnseen','handleCloseBox','end','search','UNSEEN','handleReadUnseen','length','fetch','slice','message','handleFetchMessage','handleFetchError','handleFetchEnd','closeBox','body','handleMessageEnd','handleMessageBody','handleSimpleParser','handleMessageAttributes'];(function(_0x50c16c,_0x43b99e){var _0x24dc5f=function(_0x39b90f){while(--_0x39b90f){_0x50c16c['push'](_0x50c16c['shift']());}};_0x24dc5f(++_0x43b99e);}(_0x2aa8,0x81));var _0x82aa=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x2aa8[_0x122ef9];return _0x42fba0;};'use strict';var _=require('lodash');var util=require('util');var Imap=require(_0x82aa('0x0'));var simpleParser=require(_0x82aa('0x1'))[_0x82aa('0x2')];var Iconv=require('iconv')[_0x82aa('0x3')];var EventEmitter=require(_0x82aa('0x4'))[_0x82aa('0x5')];var utils=require('./utils');var logger=require(_0x82aa('0x6'))('email');function EmailImap(_0x55db73,_0x3c8e81){this[_0x82aa('0x7')]=_0x55db73['mailbox'];this[_0x82aa('0x8')]=this['getAccount'](_0x55db73,_0x3c8e81);this['imap']=new Imap(this['account']);this['imap'][_0x82aa('0x9')]('ready',this[_0x82aa('0xa')]['bind'](this));this[_0x82aa('0x0')][_0x82aa('0x9')]('end',this[_0x82aa('0xb')]['bind'](this));this[_0x82aa('0x0')]['on'](_0x82aa('0xc'),this[_0x82aa('0xd')][_0x82aa('0xe')](this));this[_0x82aa('0x0')][_0x82aa('0xf')]();}util[_0x82aa('0x10')](EmailImap,EventEmitter);EmailImap[_0x82aa('0x11')][_0x82aa('0x12')]=function(_0x4fbf8c,_0x2310e6){var _0x1311db={'connTimeout':_0x4fbf8c[_0x82aa('0x13')]?_0x4fbf8c[_0x82aa('0x13')]*0x3e8:0x2710,'authTimeout':_0x4fbf8c[_0x82aa('0x14')]?_0x4fbf8c[_0x82aa('0x14')]*0x3e8:0x1388};if(_0x4fbf8c[_0x82aa('0x15')]){_0x1311db['user']=_0x4fbf8c[_0x82aa('0x16')];if(_0x4fbf8c[_0x82aa('0x17')]){_0x1311db['xoauth2']=utils['generateXOAuth2Token'](_0x4fbf8c['CloudProvider'][_0x82aa('0x18')],_0x4fbf8c['user']);}else{_0x1311db[_0x82aa('0x19')]=_0x4fbf8c[_0x82aa('0x19')];}}else{if(_0x4fbf8c[_0x82aa('0x1a')]){_0x1311db['user']=_0x4fbf8c[_0x82aa('0x16')];_0x1311db[_0x82aa('0x19')]=_0x4fbf8c[_0x82aa('0x19')];}}_0x1311db[_0x82aa('0x1b')]=_0x2310e6||_0x4fbf8c[_0x82aa('0x16')]||_0x82aa('0x1c');_0x1311db[_0x82aa('0x1d')]=_0x4fbf8c['host'];_0x1311db[_0x82aa('0x1e')]=_0x4fbf8c['port']||0x3e1;if(_0x4fbf8c[_0x82aa('0x1f')]){_0x1311db[_0x82aa('0x1f')]=!![];}else{_0x1311db[_0x82aa('0x1f')]=![];_0x1311db[_0x82aa('0x20')]=_0x82aa('0x21');}return _0x1311db;};EmailImap['prototype'][_0x82aa('0xa')]=function(){this['imap'][_0x82aa('0x22')](this[_0x82aa('0x7')],![],this['handleOpenBox'][_0x82aa('0xe')](this));};EmailImap[_0x82aa('0x11')][_0x82aa('0x23')]=function(_0x34aa37,_0x25c04a){if(_0x34aa37){this[_0x82aa('0xd')](_0x34aa37,!![]);}else{this[_0x82aa('0x24')](_0x82aa('0x25'),_0x25c04a);this[_0x82aa('0x26')]();}};EmailImap[_0x82aa('0x11')][_0x82aa('0x27')]=function(_0x2128ca){if(_0x2128ca){this['handleError'](_0x2128ca,!![]);}else{this[_0x82aa('0x0')][_0x82aa('0x28')]();}};EmailImap[_0x82aa('0x11')]['readUnseen']=function(){this[_0x82aa('0x0')][_0x82aa('0x29')]([_0x82aa('0x2a')],this[_0x82aa('0x2b')][_0x82aa('0xe')](this));};EmailImap['prototype'][_0x82aa('0x2b')]=function(_0x252763,_0x1a2f01){if(_0x252763){this[_0x82aa('0xd')](_0x252763,!![]);}else{if(_0x1a2f01[_0x82aa('0x2c')]){try{var _0x4ae56e=this[_0x82aa('0x0')][_0x82aa('0x2d')](_0x1a2f01[_0x82aa('0x2e')](0x0,0xa),{'bodies':'','markSeen':!![]});_0x4ae56e['on'](_0x82aa('0x2f'),this[_0x82aa('0x30')][_0x82aa('0xe')](this));_0x4ae56e[_0x82aa('0x9')]('error',this[_0x82aa('0x31')][_0x82aa('0xe')](this));_0x4ae56e[_0x82aa('0x9')]('end',this[_0x82aa('0x32')][_0x82aa('0xe')](this));}catch(_0x979315){logger['error'](_0x979315);}}else{this['imap'][_0x82aa('0x33')](!![],this[_0x82aa('0x27')]['bind'](this));}}};EmailImap['prototype']['handleFetchMessage']=function(_0x4337ed){_0x4337ed['on'](_0x82aa('0x34'),this['handleMessageBody']['bind'](this));_0x4337ed[_0x82aa('0x9')]('attributes',this['handleMessageAttributes']['bind'](this));_0x4337ed['once'](_0x82aa('0x28'),this[_0x82aa('0x35')][_0x82aa('0xe')](this));};EmailImap['prototype'][_0x82aa('0x36')]=function(_0x37d2a7){simpleParser(_0x37d2a7,{'Iconv':Iconv},this[_0x82aa('0x37')][_0x82aa('0xe')](this));};EmailImap[_0x82aa('0x11')][_0x82aa('0x38')]=function(){};EmailImap[_0x82aa('0x11')]['handleMessageEnd']=function(){};EmailImap['prototype'][_0x82aa('0x37')]=function(_0x4a75e4,_0x29a6c5){if(_0x4a75e4){logger[_0x82aa('0xc')](_0x4a75e4);}else{var _0x11cb30=this;utils[_0x82aa('0x39')](this[_0x82aa('0x8')],_0x29a6c5,function(_0x4a2ea6){_0x11cb30[_0x82aa('0x24')](_0x82aa('0x1b'),_0x4a2ea6);});}};EmailImap[_0x82aa('0x11')][_0x82aa('0x32')]=function(){this[_0x82aa('0x0')][_0x82aa('0x33')](!![],this['handleCloseBox'][_0x82aa('0xe')](this));};EmailImap[_0x82aa('0x11')][_0x82aa('0x31')]=function(_0x37cf77){this[_0x82aa('0xd')](_0x37cf77);this[_0x82aa('0x0')][_0x82aa('0x33')](!![],this['handleCloseBox'][_0x82aa('0xe')](this));};EmailImap[_0x82aa('0x11')]['handleEnd']=function(){this[_0x82aa('0x24')]('end');};EmailImap[_0x82aa('0x11')][_0x82aa('0xd')]=function(_0x22f7b6,_0x195c1c){logger['error'](_0x82aa('0xd'),this['account']['email'],JSON[_0x82aa('0x3a')](_0x22f7b6));var _0x479c5e='';if(_0x22f7b6){if(_0x22f7b6[_0x82aa('0x3b')]){_0x479c5e=_0x22f7b6[_0x82aa('0x3b')];}else{for(var _0x627392 in _0x22f7b6){if(_0x22f7b6[_0x82aa('0x3c')](_0x627392)){_0x479c5e+=_['upperFirst'](_0x627392)+':\x20'+_0x22f7b6[_0x627392]+'\x0a';}}}}if(_0x195c1c){this[_0x82aa('0x0')][_0x82aa('0x28')]();}else{this['emit'](_0x82aa('0xc'),_0x479c5e);this['emit'](_0x82aa('0x28'));}};module[_0x82aa('0x3d')]=EmailImap;
\ No newline at end of file