Built motion from commit f651e4b0a7312c0adceb5e57d6684a801a3aaf0d. Version 3.0.0...
[motion-next.git] / server / services / email / lib / imap.js
1 const a1153_0x50ce=['password','mailbox','bind','autotls','mailparser','handleMessageBody','../../../config/logger','emit','simpleParser','imap','search','parser','authentication','authTimeout','readUnseen','lodash','service','tls','handleReadUnseen','handleReady','./utils','account','handleEnd','closeBox','handleSimpleParser','handleFetchError','error','Iconv','handleOpenBox','port','ready','events','iconv','handleError','end','once','attributes','handleCloseBox','prototype','getAccount','UNSEEN','required','body','host','handleFetchMessage','length','handleMessageAttributes','user','util','handleMessageEnd','INBOX','email','box','message'];(function(_0x15a947,_0x50ce4d){const _0x1e4aab=function(_0x7d86f9){while(--_0x7d86f9){_0x15a947['push'](_0x15a947['shift']());}};_0x1e4aab(++_0x50ce4d);}(a1153_0x50ce,0x10b));const a1153_0x1e4a=function(_0x15a947,_0x50ce4d){_0x15a947=_0x15a947-0x0;let _0x1e4aab=a1153_0x50ce[_0x15a947];return _0x1e4aab;};const _0x3a3a5d=a1153_0x1e4a;'use strict';const util=require(_0x3a3a5d('0x33')),Imap=require(_0x3a3a5d('0xc')),_=require(_0x3a3a5d('0x12')),simpleParser=require(_0x3a3a5d('0x7'))[_0x3a3a5d('0xb')],Iconv=require(_0x3a3a5d('0x23'))[_0x3a3a5d('0x1e')],EventEmitter=require(_0x3a3a5d('0x22'))['EventEmitter'],utils=require(_0x3a3a5d('0x17')),logger=require(_0x3a3a5d('0x9'))(_0x3a3a5d('0x0'));function EmailImap(_0x7d86f9,_0x3f3f88){const _0x866e13=_0x3a3a5d;this[_0x866e13('0x4')]=_0x866e13('0x35'),this[_0x866e13('0x18')]=this['getAccount'](_0x7d86f9,_0x3f3f88),this['imap']=new Imap(this[_0x866e13('0x18')]),this[_0x866e13('0xc')][_0x866e13('0x26')](_0x866e13('0x21'),this[_0x866e13('0x16')]['bind'](this)),this[_0x866e13('0xc')][_0x866e13('0x26')](_0x866e13('0x25'),this['handleEnd']['bind'](this)),this[_0x866e13('0xc')]['on']('error',this[_0x866e13('0x24')][_0x866e13('0x5')](this)),this['imap']['connect']();}util['inherits'](EmailImap,EventEmitter),EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x2a')]=function(_0x1fad7f,_0x5c371a){const _0x5a3af5=_0x3a3a5d,_0x3cedf9={'connTimeout':_0x1fad7f['connTimeout']?_0x1fad7f['connTimeout']*0x3e8:0x2710,'authTimeout':_0x1fad7f[_0x5a3af5('0x10')]?_0x1fad7f['authTimeout']*0x3e8:0x1388};return _['isNil'](_0x1fad7f[_0x5a3af5('0x13')])?(_0x1fad7f[_0x5a3af5('0xf')]&&(_0x3cedf9[_0x5a3af5('0x32')]=_0x1fad7f[_0x5a3af5('0x32')],_0x3cedf9['password']=_0x1fad7f[_0x5a3af5('0x3')]),_0x3cedf9[_0x5a3af5('0x2e')]=_0x1fad7f['host'],_0x3cedf9['port']=_0x1fad7f[_0x5a3af5('0x20')]||0x3e1,_0x1fad7f[_0x5a3af5('0x14')]?_0x3cedf9[_0x5a3af5('0x14')]=!![]:(_0x3cedf9['tls']=![],_0x3cedf9[_0x5a3af5('0x6')]=_0x5a3af5('0x2c'))):(_0x3cedf9['user']=_0x1fad7f[_0x5a3af5('0x32')],_0x3cedf9[_0x5a3af5('0x3')]=_0x1fad7f[_0x5a3af5('0x3')],_0x3cedf9[_0x5a3af5('0x2e')]=utils['getHost'](_0x1fad7f[_0x5a3af5('0x13')]),_0x3cedf9['port']=0x3e1,_0x3cedf9['tls']=!![]),_0x3cedf9[_0x5a3af5('0x0')]=_0x5c371a||_0x1fad7f[_0x5a3af5('0x32')]||'anonymous@xcally.com',_0x3cedf9;},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x16')]=function(){const _0x63afed=_0x3a3a5d;this[_0x63afed('0xc')]['openBox'](this[_0x63afed('0x4')],![],this[_0x63afed('0x1f')]['bind'](this));},EmailImap[_0x3a3a5d('0x29')]['handleOpenBox']=function(_0x57a2c3,_0x53c466){const _0x361e68=_0x3a3a5d;_0x57a2c3?this[_0x361e68('0x24')](_0x57a2c3,!![]):(this['emit'](_0x361e68('0x1'),_0x53c466),this[_0x361e68('0x11')]());},EmailImap['prototype'][_0x3a3a5d('0x28')]=function(_0x26fb8e){const _0x1394bc=_0x3a3a5d;_0x26fb8e?this[_0x1394bc('0x24')](_0x26fb8e,!![]):this[_0x1394bc('0xc')][_0x1394bc('0x25')]();},EmailImap[_0x3a3a5d('0x29')]['readUnseen']=function(){const _0xb15e11=_0x3a3a5d;this[_0xb15e11('0xc')][_0xb15e11('0xd')]([_0xb15e11('0x2b')],this[_0xb15e11('0x15')][_0xb15e11('0x5')](this));},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x15')]=function(_0x1e1fa0,_0x27cb55){const _0x1106ac=_0x3a3a5d;if(_0x1e1fa0)this[_0x1106ac('0x24')](_0x1e1fa0,!![]);else{if(_0x27cb55[_0x1106ac('0x30')])try{const _0x23f34c=this[_0x1106ac('0xc')]['fetch'](_0x27cb55,{'bodies':'','markSeen':!![]});_0x23f34c['on'](_0x1106ac('0x2'),this[_0x1106ac('0x2f')][_0x1106ac('0x5')](this)),_0x23f34c[_0x1106ac('0x26')](_0x1106ac('0x1d'),this[_0x1106ac('0x1c')][_0x1106ac('0x5')](this)),_0x23f34c[_0x1106ac('0x26')](_0x1106ac('0x25'),this['handleFetchEnd'][_0x1106ac('0x5')](this));}catch(_0x3f0cd8){logger['error'](_0x3f0cd8);}else this['imap'][_0x1106ac('0x1a')](!![],this[_0x1106ac('0x28')]['bind'](this));}},EmailImap['prototype'][_0x3a3a5d('0x2f')]=function(_0x266ce4){const _0x599676=_0x3a3a5d;_0x266ce4['on'](_0x599676('0x2d'),this[_0x599676('0x8')][_0x599676('0x5')](this)),_0x266ce4[_0x599676('0x26')](_0x599676('0x27'),this[_0x599676('0x31')]['bind'](this)),_0x266ce4['once']('end',this[_0x599676('0x34')][_0x599676('0x5')](this));},EmailImap['prototype'][_0x3a3a5d('0x8')]=function(_0x2ec3cb){const _0x3f457f=_0x3a3a5d;simpleParser(_0x2ec3cb,{'Iconv':Iconv},this[_0x3f457f('0x1b')]['bind'](this));},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x31')]=function(){},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x34')]=function(){},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x1b')]=function(_0x2b4a33,_0x3aef53){const _0x3f39ff=_0x3a3a5d;if(_0x2b4a33)logger[_0x3f39ff('0x1d')](_0x2b4a33);else{const _0x427f7f=this;utils[_0x3f39ff('0xe')](this[_0x3f39ff('0x18')],_0x3aef53,function(_0x452b59){const _0x4230aa=_0x3f39ff;_0x427f7f['emit'](_0x4230aa('0x0'),_0x452b59);});}},EmailImap[_0x3a3a5d('0x29')]['handleFetchEnd']=function(){const _0x52041b=_0x3a3a5d;this[_0x52041b('0xc')]['closeBox'](!![],this[_0x52041b('0x28')][_0x52041b('0x5')](this));},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x1c')]=function(_0x502538){const _0xf37761=_0x3a3a5d;this['handleError'](_0x502538),this[_0xf37761('0xc')][_0xf37761('0x1a')](!![],this[_0xf37761('0x28')][_0xf37761('0x5')](this));},EmailImap[_0x3a3a5d('0x29')][_0x3a3a5d('0x19')]=function(){const _0x3989d0=_0x3a3a5d;this[_0x3989d0('0xa')](_0x3989d0('0x25'));},EmailImap['prototype'][_0x3a3a5d('0x24')]=function(_0x5e7570,_0x297f47){const _0x1f4a86=_0x3a3a5d;logger[_0x1f4a86('0x1d')](_0x1f4a86('0x24'),this['account'][_0x1f4a86('0x0')],JSON['stringify'](_0x5e7570));let _0x2d81a7='';if(_0x5e7570){if(_0x5e7570['textCode'])_0x2d81a7=_0x5e7570['textCode'];else for(const _0x15b28c in _0x5e7570){typeof _0x5e7570[_0x15b28c]!=='undefined'&&(_0x2d81a7+=_['upperFirst'](_0x15b28c)+':\x20'+_0x5e7570[_0x15b28c]+'\x0a');}}_0x297f47?this[_0x1f4a86('0xc')]['end']():(this[_0x1f4a86('0xa')](_0x1f4a86('0x1d'),_0x2d81a7),this[_0x1f4a86('0xa')](_0x1f4a86('0x25')));},module['exports']=EmailImap;