Built motion from commit 25580385.|2.6.2
[motion2.git] / server / services / email / lib / imap.js
index d9567e4..f6a4c88 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6455=['search','UNSEEN','handleReadUnseen','fetch','message','handleFetchMessage','handleFetchError','handleFetchEnd','closeBox','handleCloseBox','body','attributes','handleMessageAttributes','handleMessageEnd','handleMessageBody','handleSimpleParser','parser','emit','stringify','textCode','hasOwnProperty','upperFirst','exports','lodash','imap','mailparser','simpleParser','iconv','Iconv','events','./utils','../../../config/logger','email','mailbox','INBOX','account','once','ready','handleReady','bind','end','handleEnd','error','connect','inherits','prototype','getAccount','connTimeout','authTimeout','user','anonymous@xcally.com','modernAuthentication','generateXOAuth2Token','CloudProvider','data5','password','host','port','tls','required','openBox','handleOpenBox','readUnseen','handleError'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x6455,0x97));var _0x5645=function(_0x568bb8,_0x1424b3){_0x568bb8=_0x568bb8-0x0;var _0x4d1c3a=_0x6455[_0x568bb8];return _0x4d1c3a;};'use strict';var _=require(_0x5645('0x0'));var util=require('util');var Imap=require(_0x5645('0x1'));var simpleParser=require(_0x5645('0x2'))[_0x5645('0x3')];var Iconv=require(_0x5645('0x4'))[_0x5645('0x5')];var EventEmitter=require(_0x5645('0x6'))['EventEmitter'];var utils=require(_0x5645('0x7'));var logger=require(_0x5645('0x8'))(_0x5645('0x9'));function EmailImap(_0x9400a8,_0x3a635d){this[_0x5645('0xa')]=_0x5645('0xb');this[_0x5645('0xc')]=this['getAccount'](_0x9400a8,_0x3a635d);this['imap']=new Imap(this[_0x5645('0xc')]);this[_0x5645('0x1')][_0x5645('0xd')](_0x5645('0xe'),this[_0x5645('0xf')][_0x5645('0x10')](this));this['imap'][_0x5645('0xd')](_0x5645('0x11'),this[_0x5645('0x12')][_0x5645('0x10')](this));this['imap']['on'](_0x5645('0x13'),this['handleError'][_0x5645('0x10')](this));this[_0x5645('0x1')][_0x5645('0x14')]();}util[_0x5645('0x15')](EmailImap,EventEmitter);EmailImap[_0x5645('0x16')][_0x5645('0x17')]=function(_0x45cbe8,_0x2270a1){var _0x50449c={'connTimeout':_0x45cbe8[_0x5645('0x18')]?_0x45cbe8[_0x5645('0x18')]*0x3e8:0x2710,'authTimeout':_0x45cbe8[_0x5645('0x19')]?_0x45cbe8['authTimeout']*0x3e8:0x1388};if(_0x45cbe8['service']){_0x50449c[_0x5645('0x1a')]=_0x45cbe8[_0x5645('0x1a')];_0x50449c['email']=_0x2270a1||_0x45cbe8[_0x5645('0x1a')]||_0x5645('0x1b');if(_0x45cbe8[_0x5645('0x1c')]){_0x50449c['xoauth2']=utils[_0x5645('0x1d')](_0x45cbe8[_0x5645('0x1e')][_0x5645('0x1f')],_0x45cbe8[_0x5645('0x1a')]);}else{_0x50449c['password']=_0x45cbe8[_0x5645('0x20')];}}else{if(_0x45cbe8['authentication']){_0x50449c['user']=_0x45cbe8[_0x5645('0x1a')];_0x50449c[_0x5645('0x20')]=_0x45cbe8[_0x5645('0x20')];}}_0x50449c['host']=_0x45cbe8[_0x5645('0x21')];_0x50449c['port']=_0x45cbe8[_0x5645('0x22')]||0x3e1;if(_0x45cbe8['tls']){_0x50449c['tls']=!![];}else{_0x50449c[_0x5645('0x23')]=![];_0x50449c['autotls']=_0x5645('0x24');}return _0x50449c;};EmailImap[_0x5645('0x16')]['handleReady']=function(){this[_0x5645('0x1')][_0x5645('0x25')](this[_0x5645('0xa')],![],this['handleOpenBox'][_0x5645('0x10')](this));};EmailImap[_0x5645('0x16')][_0x5645('0x26')]=function(_0x46b33a,_0x568fd6){if(_0x46b33a){this['handleError'](_0x46b33a,!![]);}else{this['emit']('box',_0x568fd6);this[_0x5645('0x27')]();}};EmailImap['prototype']['handleCloseBox']=function(_0xfbe837){if(_0xfbe837){this[_0x5645('0x28')](_0xfbe837,!![]);}else{this[_0x5645('0x1')][_0x5645('0x11')]();}};EmailImap[_0x5645('0x16')][_0x5645('0x27')]=function(){this[_0x5645('0x1')][_0x5645('0x29')]([_0x5645('0x2a')],this[_0x5645('0x2b')][_0x5645('0x10')](this));};EmailImap[_0x5645('0x16')][_0x5645('0x2b')]=function(_0xa2a4a1,_0x52ba45){if(_0xa2a4a1){this[_0x5645('0x28')](_0xa2a4a1,!![]);}else{if(_0x52ba45['length']){try{var _0x12aea2=this[_0x5645('0x1')][_0x5645('0x2c')](_0x52ba45,{'bodies':'','markSeen':!![]});_0x12aea2['on'](_0x5645('0x2d'),this[_0x5645('0x2e')][_0x5645('0x10')](this));_0x12aea2['once']('error',this[_0x5645('0x2f')][_0x5645('0x10')](this));_0x12aea2[_0x5645('0xd')](_0x5645('0x11'),this[_0x5645('0x30')][_0x5645('0x10')](this));}catch(_0x44d519){logger[_0x5645('0x13')](_0x44d519);}}else{this[_0x5645('0x1')][_0x5645('0x31')](!![],this[_0x5645('0x32')]['bind'](this));}}};EmailImap['prototype'][_0x5645('0x2e')]=function(_0x5a7e11){_0x5a7e11['on'](_0x5645('0x33'),this['handleMessageBody'][_0x5645('0x10')](this));_0x5a7e11['once'](_0x5645('0x34'),this[_0x5645('0x35')][_0x5645('0x10')](this));_0x5a7e11[_0x5645('0xd')](_0x5645('0x11'),this[_0x5645('0x36')]['bind'](this));};EmailImap[_0x5645('0x16')][_0x5645('0x37')]=function(_0x13ede1){simpleParser(_0x13ede1,{'Iconv':Iconv},this[_0x5645('0x38')][_0x5645('0x10')](this));};EmailImap[_0x5645('0x16')][_0x5645('0x35')]=function(){};EmailImap[_0x5645('0x16')]['handleMessageEnd']=function(){};EmailImap[_0x5645('0x16')]['handleSimpleParser']=function(_0x2f28be,_0x2aaf8f){if(_0x2f28be){logger[_0x5645('0x13')](_0x2f28be);}else{var _0x397679=this;utils[_0x5645('0x39')](this['account'],_0x2aaf8f,function(_0x20298f){_0x397679[_0x5645('0x3a')](_0x5645('0x9'),_0x20298f);});}};EmailImap[_0x5645('0x16')][_0x5645('0x30')]=function(){this[_0x5645('0x1')][_0x5645('0x31')](!![],this[_0x5645('0x32')][_0x5645('0x10')](this));};EmailImap[_0x5645('0x16')][_0x5645('0x2f')]=function(_0x19bbdb){this[_0x5645('0x28')](_0x19bbdb);this[_0x5645('0x1')][_0x5645('0x31')](!![],this[_0x5645('0x32')]['bind'](this));};EmailImap[_0x5645('0x16')][_0x5645('0x12')]=function(){this['emit'](_0x5645('0x11'));};EmailImap[_0x5645('0x16')]['handleError']=function(_0x11245e,_0x9eef68){logger[_0x5645('0x13')](_0x5645('0x28'),this[_0x5645('0xc')][_0x5645('0x9')],JSON[_0x5645('0x3b')](_0x11245e));var _0x5a5eee='';if(_0x11245e){if(_0x11245e['textCode']){_0x5a5eee=_0x11245e[_0x5645('0x3c')];}else{for(var _0x1ffbd4 in _0x11245e){if(_0x11245e[_0x5645('0x3d')](_0x1ffbd4)){_0x5a5eee+=_[_0x5645('0x3e')](_0x1ffbd4)+':\x20'+_0x11245e[_0x1ffbd4]+'\x0a';}}}}if(_0x9eef68){this[_0x5645('0x1')][_0x5645('0x11')]();}else{this[_0x5645('0x3a')](_0x5645('0x13'),_0x5a5eee);this[_0x5645('0x3a')](_0x5645('0x11'));}};module[_0x5645('0x3f')]=EmailImap;
\ No newline at end of file
+var _0x4bd3=['body','handleMessageBody','attributes','handleMessageAttributes','handleSimpleParser','handleMessageEnd','parser','handleEnd','stringify','textCode','upperFirst','exports','lodash','imap','mailparser','events','EventEmitter','./utils','email','mailbox','INBOX','getAccount','account','once','ready','bind','end','connect','inherits','prototype','connTimeout','service','user','anonymous@xcally.com','modernAuthentication','xoauth2','generateXOAuth2Token','CloudProvider','data5','password','authentication','host','port','tls','autotls','openBox','handleOpenBox','handleError','emit','readUnseen','handleCloseBox','search','UNSEEN','handleReadUnseen','fetch','error','handleFetchError','handleFetchEnd','closeBox','handleFetchMessage'];(function(_0x5ca41a,_0x79b402){var _0x2ae67f=function(_0x8e089d){while(--_0x8e089d){_0x5ca41a['push'](_0x5ca41a['shift']());}};_0x2ae67f(++_0x79b402);}(_0x4bd3,0x174));var _0x34bd=function(_0x4a9308,_0x2f0b1b){_0x4a9308=_0x4a9308-0x0;var _0x83052f=_0x4bd3[_0x4a9308];return _0x83052f;};'use strict';var _=require(_0x34bd('0x0'));var util=require('util');var Imap=require(_0x34bd('0x1'));var simpleParser=require(_0x34bd('0x2'))['simpleParser'];var Iconv=require('iconv')['Iconv'];var EventEmitter=require(_0x34bd('0x3'))[_0x34bd('0x4')];var utils=require(_0x34bd('0x5'));var logger=require('../../../config/logger')(_0x34bd('0x6'));function EmailImap(_0x2a15a2,_0x5c2a7a){this[_0x34bd('0x7')]=_0x34bd('0x8');this['account']=this[_0x34bd('0x9')](_0x2a15a2,_0x5c2a7a);this[_0x34bd('0x1')]=new Imap(this[_0x34bd('0xa')]);this[_0x34bd('0x1')][_0x34bd('0xb')](_0x34bd('0xc'),this['handleReady'][_0x34bd('0xd')](this));this[_0x34bd('0x1')][_0x34bd('0xb')](_0x34bd('0xe'),this['handleEnd']['bind'](this));this[_0x34bd('0x1')]['on']('error',this['handleError'][_0x34bd('0xd')](this));this[_0x34bd('0x1')][_0x34bd('0xf')]();}util[_0x34bd('0x10')](EmailImap,EventEmitter);EmailImap[_0x34bd('0x11')][_0x34bd('0x9')]=function(_0x4134ee,_0x236f6b){var _0xf6d2f2={'connTimeout':_0x4134ee['connTimeout']?_0x4134ee[_0x34bd('0x12')]*0x3e8:0x2710,'authTimeout':_0x4134ee['authTimeout']?_0x4134ee['authTimeout']*0x3e8:0x1388};if(_0x4134ee[_0x34bd('0x13')]){_0xf6d2f2[_0x34bd('0x14')]=_0x4134ee[_0x34bd('0x14')];_0xf6d2f2[_0x34bd('0x6')]=_0x236f6b||_0x4134ee[_0x34bd('0x14')]||_0x34bd('0x15');if(_0x4134ee[_0x34bd('0x16')]){_0xf6d2f2[_0x34bd('0x17')]=utils[_0x34bd('0x18')](_0x4134ee[_0x34bd('0x19')][_0x34bd('0x1a')],_0x4134ee['user']);}else{_0xf6d2f2[_0x34bd('0x1b')]=_0x4134ee[_0x34bd('0x1b')];}}else{if(_0x4134ee[_0x34bd('0x1c')]){_0xf6d2f2[_0x34bd('0x14')]=_0x4134ee[_0x34bd('0x14')];_0xf6d2f2[_0x34bd('0x1b')]=_0x4134ee[_0x34bd('0x1b')];}}_0xf6d2f2[_0x34bd('0x1d')]=_0x4134ee[_0x34bd('0x1d')];_0xf6d2f2['port']=_0x4134ee[_0x34bd('0x1e')]||0x3e1;if(_0x4134ee[_0x34bd('0x1f')]){_0xf6d2f2[_0x34bd('0x1f')]=!![];}else{_0xf6d2f2[_0x34bd('0x1f')]=![];_0xf6d2f2[_0x34bd('0x20')]='required';}return _0xf6d2f2;};EmailImap['prototype']['handleReady']=function(){this['imap'][_0x34bd('0x21')](this['mailbox'],![],this[_0x34bd('0x22')][_0x34bd('0xd')](this));};EmailImap[_0x34bd('0x11')]['handleOpenBox']=function(_0x41bffd,_0x14479a){if(_0x41bffd){this[_0x34bd('0x23')](_0x41bffd,!![]);}else{this[_0x34bd('0x24')]('box',_0x14479a);this[_0x34bd('0x25')]();}};EmailImap[_0x34bd('0x11')][_0x34bd('0x26')]=function(_0x3e4dc3){if(_0x3e4dc3){this['handleError'](_0x3e4dc3,!![]);}else{this[_0x34bd('0x1')][_0x34bd('0xe')]();}};EmailImap['prototype'][_0x34bd('0x25')]=function(){this[_0x34bd('0x1')][_0x34bd('0x27')]([_0x34bd('0x28')],this[_0x34bd('0x29')][_0x34bd('0xd')](this));};EmailImap[_0x34bd('0x11')]['handleReadUnseen']=function(_0x43b92d,_0x4156f5){if(_0x43b92d){this['handleError'](_0x43b92d,!![]);}else{if(_0x4156f5['length']){try{var _0x38bdba=this[_0x34bd('0x1')][_0x34bd('0x2a')](_0x4156f5,{'bodies':'','markSeen':!![]});_0x38bdba['on']('message',this['handleFetchMessage'][_0x34bd('0xd')](this));_0x38bdba[_0x34bd('0xb')](_0x34bd('0x2b'),this[_0x34bd('0x2c')]['bind'](this));_0x38bdba[_0x34bd('0xb')](_0x34bd('0xe'),this[_0x34bd('0x2d')][_0x34bd('0xd')](this));}catch(_0x2ef58f){logger[_0x34bd('0x2b')](_0x2ef58f);}}else{this['imap'][_0x34bd('0x2e')](!![],this['handleCloseBox'][_0x34bd('0xd')](this));}}};EmailImap[_0x34bd('0x11')][_0x34bd('0x2f')]=function(_0x4e9e70){_0x4e9e70['on'](_0x34bd('0x30'),this[_0x34bd('0x31')]['bind'](this));_0x4e9e70[_0x34bd('0xb')](_0x34bd('0x32'),this[_0x34bd('0x33')]['bind'](this));_0x4e9e70[_0x34bd('0xb')](_0x34bd('0xe'),this['handleMessageEnd'][_0x34bd('0xd')](this));};EmailImap[_0x34bd('0x11')][_0x34bd('0x31')]=function(_0x243f6c){simpleParser(_0x243f6c,{'Iconv':Iconv},this[_0x34bd('0x34')][_0x34bd('0xd')](this));};EmailImap['prototype']['handleMessageAttributes']=function(){};EmailImap['prototype'][_0x34bd('0x35')]=function(){};EmailImap[_0x34bd('0x11')]['handleSimpleParser']=function(_0x5b5f86,_0x13d2f0){if(_0x5b5f86){logger['error'](_0x5b5f86);}else{var _0x597a82=this;utils[_0x34bd('0x36')](this[_0x34bd('0xa')],_0x13d2f0,function(_0xa61859){_0x597a82[_0x34bd('0x24')](_0x34bd('0x6'),_0xa61859);});}};EmailImap['prototype']['handleFetchEnd']=function(){this[_0x34bd('0x1')]['closeBox'](!![],this[_0x34bd('0x26')][_0x34bd('0xd')](this));};EmailImap[_0x34bd('0x11')][_0x34bd('0x2c')]=function(_0x1ddb39){this['handleError'](_0x1ddb39);this[_0x34bd('0x1')][_0x34bd('0x2e')](!![],this[_0x34bd('0x26')][_0x34bd('0xd')](this));};EmailImap['prototype'][_0x34bd('0x37')]=function(){this['emit'](_0x34bd('0xe'));};EmailImap[_0x34bd('0x11')]['handleError']=function(_0x279765,_0x4cf516){logger[_0x34bd('0x2b')](_0x34bd('0x23'),this[_0x34bd('0xa')][_0x34bd('0x6')],JSON[_0x34bd('0x38')](_0x279765));var _0xb0f197='';if(_0x279765){if(_0x279765[_0x34bd('0x39')]){_0xb0f197=_0x279765['textCode'];}else{for(var _0x4986bb in _0x279765){if(_0x279765['hasOwnProperty'](_0x4986bb)){_0xb0f197+=_[_0x34bd('0x3a')](_0x4986bb)+':\x20'+_0x279765[_0x4986bb]+'\x0a';}}}}if(_0x4cf516){this[_0x34bd('0x1')][_0x34bd('0xe')]();}else{this[_0x34bd('0x24')]('error',_0xb0f197);this[_0x34bd('0x24')](_0x34bd('0xe'));}};module[_0x34bd('0x3b')]=EmailImap;
\ No newline at end of file