Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / services / email / lib / imap.js
index ccf2f77..88957f4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x1e8d=['account','getAccount','once','ready','handleReady','end','handleEnd','bind','error','handleError','connect','inherits','prototype','connTimeout','authTimeout','service','user','modernAuthentication','xoauth2','generateXOAuth2Token','data5','password','email','anonymous@xcally.com','host','port','tls','autotls','required','handleOpenBox','emit','box','readUnseen','handleCloseBox','search','UNSEEN','handleReadUnseen','slice','message','handleFetchMessage','handleFetchError','closeBox','handleMessageBody','handleMessageEnd','handleSimpleParser','handleMessageAttributes','handleFetchEnd','stringify','textCode','exports','lodash','util','imap','mailparser','simpleParser','iconv','Iconv','events','EventEmitter','./utils','mailbox'];(function(_0x2be8c2,_0x14a4b5){var _0x97f531=function(_0xcee58d){while(--_0xcee58d){_0x2be8c2['push'](_0x2be8c2['shift']());}};_0x97f531(++_0x14a4b5);}(_0x1e8d,0x6f));var _0xd1e8=function(_0x260b23,_0x2d6117){_0x260b23=_0x260b23-0x0;var _0x9526b8=_0x1e8d[_0x260b23];return _0x9526b8;};'use strict';var _=require(_0xd1e8('0x0'));var util=require(_0xd1e8('0x1'));var Imap=require(_0xd1e8('0x2'));var simpleParser=require(_0xd1e8('0x3'))[_0xd1e8('0x4')];var Iconv=require(_0xd1e8('0x5'))[_0xd1e8('0x6')];var EventEmitter=require(_0xd1e8('0x7'))[_0xd1e8('0x8')];var utils=require(_0xd1e8('0x9'));var logger=require('../../../config/logger')('email');function EmailImap(_0x1daa61,_0x1fd059){this[_0xd1e8('0xa')]=_0x1daa61['mailbox'];this[_0xd1e8('0xb')]=this[_0xd1e8('0xc')](_0x1daa61,_0x1fd059);this['imap']=new Imap(this[_0xd1e8('0xb')]);this[_0xd1e8('0x2')][_0xd1e8('0xd')](_0xd1e8('0xe'),this[_0xd1e8('0xf')]['bind'](this));this[_0xd1e8('0x2')][_0xd1e8('0xd')](_0xd1e8('0x10'),this[_0xd1e8('0x11')][_0xd1e8('0x12')](this));this['imap']['on'](_0xd1e8('0x13'),this[_0xd1e8('0x14')][_0xd1e8('0x12')](this));this[_0xd1e8('0x2')][_0xd1e8('0x15')]();}util[_0xd1e8('0x16')](EmailImap,EventEmitter);EmailImap[_0xd1e8('0x17')]['getAccount']=function(_0x411248,_0x105ef4){var _0xd1c35c={'connTimeout':_0x411248['connTimeout']?_0x411248[_0xd1e8('0x18')]*0x3e8:0x2710,'authTimeout':_0x411248[_0xd1e8('0x19')]?_0x411248[_0xd1e8('0x19')]*0x3e8:0x1388};if(_0x411248[_0xd1e8('0x1a')]){_0xd1c35c['user']=_0x411248[_0xd1e8('0x1b')];if(_0x411248[_0xd1e8('0x1c')]){_0xd1c35c[_0xd1e8('0x1d')]=utils[_0xd1e8('0x1e')](_0x411248['CloudProvider'][_0xd1e8('0x1f')],_0x411248[_0xd1e8('0x1b')]);}else{_0xd1c35c['password']=_0x411248[_0xd1e8('0x20')];}}else{if(_0x411248['authentication']){_0xd1c35c[_0xd1e8('0x1b')]=_0x411248['user'];_0xd1c35c[_0xd1e8('0x20')]=_0x411248[_0xd1e8('0x20')];}}_0xd1c35c[_0xd1e8('0x21')]=_0x105ef4||_0x411248['user']||_0xd1e8('0x22');_0xd1c35c[_0xd1e8('0x23')]=_0x411248[_0xd1e8('0x23')];_0xd1c35c['port']=_0x411248[_0xd1e8('0x24')]||0x3e1;if(_0x411248[_0xd1e8('0x25')]){_0xd1c35c['tls']=!![];}else{_0xd1c35c[_0xd1e8('0x25')]=![];_0xd1c35c[_0xd1e8('0x26')]=_0xd1e8('0x27');}return _0xd1c35c;};EmailImap[_0xd1e8('0x17')]['handleReady']=function(){this[_0xd1e8('0x2')]['openBox'](this['mailbox'],![],this[_0xd1e8('0x28')]['bind'](this));};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x28')]=function(_0x69a542,_0x28635a){if(_0x69a542){this['handleError'](_0x69a542,!![]);}else{this[_0xd1e8('0x29')](_0xd1e8('0x2a'),_0x28635a);this[_0xd1e8('0x2b')]();}};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x2c')]=function(_0x4351a0){if(_0x4351a0){this['handleError'](_0x4351a0,!![]);}else{this[_0xd1e8('0x2')][_0xd1e8('0x10')]();}};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x2b')]=function(){this['imap'][_0xd1e8('0x2d')]([_0xd1e8('0x2e')],this[_0xd1e8('0x2f')][_0xd1e8('0x12')](this));};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x2f')]=function(_0xcd8347,_0x52f351){if(_0xcd8347){this[_0xd1e8('0x14')](_0xcd8347,!![]);}else{if(_0x52f351['length']){try{var _0x2fef33=this[_0xd1e8('0x2')]['fetch'](_0x52f351[_0xd1e8('0x30')](0x0,0xa),{'bodies':'','markSeen':!![]});_0x2fef33['on'](_0xd1e8('0x31'),this[_0xd1e8('0x32')][_0xd1e8('0x12')](this));_0x2fef33[_0xd1e8('0xd')]('error',this[_0xd1e8('0x33')][_0xd1e8('0x12')](this));_0x2fef33[_0xd1e8('0xd')](_0xd1e8('0x10'),this['handleFetchEnd'][_0xd1e8('0x12')](this));}catch(_0x4ed319){logger[_0xd1e8('0x13')](_0x4ed319);}}else{this[_0xd1e8('0x2')][_0xd1e8('0x34')](!![],this[_0xd1e8('0x2c')]['bind'](this));}}};EmailImap['prototype']['handleFetchMessage']=function(_0x4cec0e){_0x4cec0e['on']('body',this[_0xd1e8('0x35')][_0xd1e8('0x12')](this));_0x4cec0e['once']('attributes',this['handleMessageAttributes'][_0xd1e8('0x12')](this));_0x4cec0e['once'](_0xd1e8('0x10'),this[_0xd1e8('0x36')][_0xd1e8('0x12')](this));};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x35')]=function(_0x38c0ba){simpleParser(_0x38c0ba,{'Iconv':Iconv},this[_0xd1e8('0x37')][_0xd1e8('0x12')](this));};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x38')]=function(){};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x36')]=function(){};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x37')]=function(_0x13d296,_0x30f603){if(_0x13d296){logger[_0xd1e8('0x13')](_0x13d296);}else{var _0x146fec=this;utils['parser'](this[_0xd1e8('0xb')],_0x30f603,function(_0x23c05d){_0x146fec[_0xd1e8('0x29')](_0xd1e8('0x21'),_0x23c05d);});}};EmailImap['prototype'][_0xd1e8('0x39')]=function(){this[_0xd1e8('0x2')][_0xd1e8('0x34')](!![],this['handleCloseBox'][_0xd1e8('0x12')](this));};EmailImap[_0xd1e8('0x17')]['handleFetchError']=function(_0x4e385e){this[_0xd1e8('0x14')](_0x4e385e);this[_0xd1e8('0x2')][_0xd1e8('0x34')](!![],this[_0xd1e8('0x2c')][_0xd1e8('0x12')](this));};EmailImap['prototype'][_0xd1e8('0x11')]=function(){this[_0xd1e8('0x29')]('end');};EmailImap[_0xd1e8('0x17')][_0xd1e8('0x14')]=function(_0x30b06c,_0x32ec8e){logger['error'](_0xd1e8('0x14'),this['account'][_0xd1e8('0x21')],JSON[_0xd1e8('0x3a')](_0x30b06c));var _0x150221='';if(_0x30b06c){if(_0x30b06c['textCode']){_0x150221=_0x30b06c[_0xd1e8('0x3b')];}else{for(var _0x43d7ca in _0x30b06c){if(_0x30b06c['hasOwnProperty'](_0x43d7ca)){_0x150221+=_['upperFirst'](_0x43d7ca)+':\x20'+_0x30b06c[_0x43d7ca]+'\x0a';}}}}if(_0x32ec8e){this[_0xd1e8('0x2')]['end']();}else{this[_0xd1e8('0x29')](_0xd1e8('0x13'),_0x150221);this[_0xd1e8('0x29')](_0xd1e8('0x10'));}};module[_0xd1e8('0x3c')]=EmailImap;
\ No newline at end of file