Built motion from commit f651e4b0a7312c0adceb5e57d6684a801a3aaf0d. Version 3.0.0...
[motion-next.git] / server / services / email / lib / utils.js
index da3a767..a4354e7 100644 (file)
@@ -1 +1 @@
-const a1155_0xdf92=['yahoo','split','name','textAsHtml','getHost','path','hotmail','subject','randomstring','parseBuffer','message','bcc','info','node-tnef','originTo','format','originCc','util','type','body','%s-%s','gmail','@xcally.com','replace','content','Title','application/ms-tnef','writeFileSync','imap.gmail.com','filename','attach','html','includes','messageId','contentType','head','isEmpty','outlook.office365.com','generate','files/attachments/','length','outlook365','join','root','anonymous','test','imap-mail.outlook.com','attachments','../../../config/logger','<p>Empty\x20message</p>','Attachments','Anonymous','parser','push','pop','from','slice','email','inReplyTo','attachment','BodyHTML','value','now','Data','address'];(function(_0xed7543,_0xdf92e9){const _0x41b150=function(_0x1c373a){while(--_0x1c373a){_0xed7543['push'](_0xed7543['shift']());}};_0x41b150(++_0xdf92e9);}(a1155_0xdf92,0x9d));const a1155_0x41b1=function(_0xed7543,_0xdf92e9){_0xed7543=_0xed7543-0x0;let _0x41b150=a1155_0xdf92[_0xed7543];return _0x41b150;};const _0x2fc22f=a1155_0x41b1;'use strict';const _=require('lodash'),moment=require('moment'),random=require(_0x2fc22f('0x2e')),fs=require('fs'),path=require(_0x2fc22f('0x2b')),util=require(_0x2fc22f('0x37')),tnef=require(_0x2fc22f('0x33')),logger=require(_0x2fc22f('0x15'))(_0x2fc22f('0x1e')),config=require('../../../config/environment');function getAddress(_0x1c373a){const _0x1947ee=_0x2fc22f,_0x443e24=_['head'](_0x1c373a[_0x1947ee('0x22')]);return _0x443e24&&_0x443e24['address']?_0x443e24[_0x1947ee('0x25')]:_0x1947ee('0x11')+random[_0x1947ee('0xb')](0x6)+_0x1947ee('0x3c');}function getFirstName(_0x304f8b){const _0x25e2c8=_0x2fc22f,_0x76daf8=_[_0x25e2c8('0x8')](_0x304f8b[_0x25e2c8('0x22')]);if(_0x76daf8&&_0x76daf8[_0x25e2c8('0x28')]){const _0xbd0897=_0x76daf8[_0x25e2c8('0x28')][_0x25e2c8('0x27')](/\s+/);return _0xbd0897[_0x25e2c8('0xd')]?_0xbd0897[_0x25e2c8('0x1d')](0x0,-0x1)[_0x25e2c8('0xf')]('\x20'):_0x76daf8['name'];}return _0x25e2c8('0x18');}function getLastName(_0x344231){const _0x5868f2=_0x2fc22f,_0x380e62=_['head'](_0x344231['value']);if(_0x380e62&&_0x380e62[_0x5868f2('0x28')]){const _0x529abe=_0x380e62['name'][_0x5868f2('0x27')](/\s+/);return _0x529abe[_0x5868f2('0xd')]>0x1?_0x529abe[_0x5868f2('0x1b')]():'';}return'';}function getMails(_0x360a65,_0x79ae3c){const _0x53ecbf=_0x2fc22f;let _0x39c674='';for(let _0x44a9f9=0x0;_0x44a9f9<_0x79ae3c[_0x53ecbf('0x22')]['length'];_0x44a9f9+=0x1){_0x79ae3c[_0x53ecbf('0x22')][_0x44a9f9][_0x53ecbf('0x25')]!==_0x360a65&&(!_[_0x53ecbf('0x9')](_0x39c674)&&(_0x39c674+=','),_0x39c674+=_0x79ae3c[_0x53ecbf('0x22')][_0x44a9f9][_0x53ecbf('0x28')]||_0x79ae3c['value'][_0x44a9f9][_0x53ecbf('0x25')]||'',_0x39c674+='\x20<',_0x39c674+=_0x79ae3c[_0x53ecbf('0x22')][_0x44a9f9]['address']?_0x79ae3c[_0x53ecbf('0x22')][_0x44a9f9]['address']:_0x53ecbf('0x11')+random['generate'](0x6)+_0x53ecbf('0x3c'),_0x39c674+='>');}return _0x39c674;}function parseEmail(_0x4baeb2,_0xb08489,_0x5740f8){const _0xb9d59=_0x2fc22f;if(_0xb08489[_0xb9d59('0x4')]){const _0x3047bd=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x3047bd[_0xb9d59('0x12')](_0xb08489['html'])){_0xb08489[_0xb9d59('0x4')]=_0xb08489[_0xb9d59('0x4')]['replace'](_0x3047bd,'');}_0x5740f8['body']=_0xb08489[_0xb9d59('0x4')];}else _0x5740f8[_0xb9d59('0x39')]=_0xb08489[_0xb9d59('0x29')];_0x5740f8[_0xb9d59('0x39')]&&(_0x5740f8['body']=_0x5740f8[_0xb9d59('0x39')][_0xb9d59('0x3d')](/<a\s+/gi,'<a\x20target=\x22_blank\x22\x20'));if(_0xb08489['to']){_0x5740f8[_0xb9d59('0x30')][_0xb9d59('0x34')]=getMails(null,_0xb08489['to']);const _0x59e296=getMails(_0x4baeb2[_0xb9d59('0x1e')],_0xb08489['to']);!_[_0xb9d59('0x9')](_0x59e296)&&(_0x5740f8[_0xb9d59('0x30')]['cc']+=_0x59e296);}if(_0xb08489['cc']){_0x5740f8[_0xb9d59('0x30')][_0xb9d59('0x36')]=getMails(null,_0xb08489['cc']);const _0x521021=getMails(_0x4baeb2[_0xb9d59('0x1e')],_0xb08489['cc']);!_['isEmpty'](_0x521021)&&(!_[_0xb9d59('0x9')](_0x5740f8['message']['cc'])&&(_0x5740f8['message']['cc']+=','),_0x5740f8[_0xb9d59('0x30')]['cc']+=_0x521021);}!_[_0xb9d59('0x5')](_0x5740f8['message'][_0xb9d59('0x34')],_0x4baeb2[_0xb9d59('0x1e')])&&!_[_0xb9d59('0x5')](_0x5740f8[_0xb9d59('0x30')]['originCc'],_0x4baeb2[_0xb9d59('0x1e')])&&(_0x5740f8[_0xb9d59('0x30')][_0xb9d59('0x31')]=_0x4baeb2[_0xb9d59('0x1e')]);if(_0xb08489[_0xb9d59('0x14')]&&_0xb08489['attachments'][_0xb9d59('0xd')]){_0x5740f8[_0xb9d59('0x30')][_0xb9d59('0x3')]=_0xb08489[_0xb9d59('0x14')][_0xb9d59('0xd')];for(let _0x32c2c7=0x0,_0x4c3db9,_0x3c00e6,_0x3788d5;_0x32c2c7<_0xb08489[_0xb9d59('0x14')]['length'];_0x32c2c7+=0x1){_0xb08489[_0xb9d59('0x14')][_0x32c2c7][_0xb9d59('0x38')]===_0xb9d59('0x20')&&(_0x3788d5=_0xb08489['attachments'][_0x32c2c7][_0xb9d59('0x2')]||'attachment-'+_0x32c2c7,_0x4c3db9=util[_0xb9d59('0x35')](_0xb9d59('0x3a'),Date[_0xb9d59('0x23')](),_0x3788d5),_0x3c00e6=path[_0xb9d59('0xf')](config[_0xb9d59('0x10')],_0xb9d59('0xc'),_0x4c3db9),fs[_0xb9d59('0x0')](_0x3c00e6,_0xb08489[_0xb9d59('0x14')][_0x32c2c7][_0xb9d59('0x3e')]),_0x5740f8[_0xb9d59('0x30')]['attachments'][_0xb9d59('0x1a')]({'name':_0x3788d5,'basename':_0x4c3db9,'type':_0xb08489['attachments'][_0x32c2c7][_0xb9d59('0x7')],'filepath':_0x3c00e6}));}}return _0x5740f8;}exports[_0x2fc22f('0x19')]=function(_0x5dd321,_0x3ca015,_0x27780f){const _0x24c90d=_0x2fc22f,_0xef02b4={'from':getAddress(_0x3ca015[_0x24c90d('0x1c')]),'firstName':getFirstName(_0x3ca015['from']),'lastName':getLastName(_0x3ca015[_0x24c90d('0x1c')]),'mapKey':_0x24c90d('0x1e'),'message':{'from':getMails(_0x5dd321[_0x24c90d('0x1e')],_0x3ca015[_0x24c90d('0x1c')]),'to':_0x5dd321['email'],'cc':'','subject':_0x3ca015[_0x24c90d('0x2d')]||'','messageId':_0x3ca015['messageId'],'inReplyTo':_0x3ca015[_0x24c90d('0x1f')],'sentAt':moment(_0x3ca015['date'])[_0x24c90d('0x35')]('YYYY-MM-DD\x20HH:mm:ss'),'attach':![],'attachments':[]}};if(!_0x3ca015[_0x24c90d('0x4')]&&!_0x3ca015[_0x24c90d('0x29')]){const _0x56a8ab=_['filter'](_0x3ca015[_0x24c90d('0x14')],{'contentType':_0x24c90d('0x40')});_0x56a8ab[_0x24c90d('0xd')]?(logger[_0x24c90d('0x32')](util['format']('Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system',_0x3ca015[_0x24c90d('0x6')])),tnef[_0x24c90d('0x2f')](_['first'](_0x56a8ab)[_0x24c90d('0x3e')],function(_0x18abe3,_0x5e8ca0){const _0x5a8d07=_0x24c90d;if(_0x5e8ca0){_0x3ca015[_0x5a8d07('0x4')]=_0x5e8ca0[_0x5a8d07('0x21')]||_0x5a8d07('0x16');if(_0x5e8ca0[_0x5a8d07('0x17')])for(let _0x303b12=0x0;_0x303b12<_0x5e8ca0[_0x5a8d07('0x17')][_0x5a8d07('0xd')];_0x303b12++){const _0x25d617=_0x5e8ca0[_0x5a8d07('0x17')][_0x303b12];_0xef02b4['message'][_0x5a8d07('0x14')]['push']({'filename':_0x25d617[_0x5a8d07('0x3f')],'content':Buffer[_0x5a8d07('0x1c')](_0x25d617[_0x5a8d07('0x24')])});}}_0x27780f(parseEmail(_0x5dd321,_0x3ca015,_0xef02b4));})):(_0x3ca015[_0x24c90d('0x4')]=_0x24c90d('0x16'),_0x27780f(parseEmail(_0x5dd321,_0x3ca015,_0xef02b4)));}else _0x27780f(parseEmail(_0x5dd321,_0x3ca015,_0xef02b4));},exports[_0x2fc22f('0x2a')]=function(_0x3ff9ad){const _0x284bba=_0x2fc22f;switch(_0x3ff9ad){case _0x284bba('0x3b'):return _0x284bba('0x1');case _0x284bba('0x26'):return'imap.mail.yahoo.com';case _0x284bba('0x2c'):return _0x284bba('0x13');case _0x284bba('0xe'):return _0x284bba('0xa');}return'127.0.0.1';};
\ No newline at end of file
+const a1155_0x51a2=['date','moment','lodash','util','from','Attachments','path','format','attach','info','messageId','BodyHTML','filter','inReplyTo','message','hotmail','imap-mail.outlook.com','files/attachments/','Anonymous','%s-%s','parseBuffer','originCc','head','replace','parser','../../../config/environment','getHost','node-tnef','randomstring','address','bcc','originTo','pop','body','test','value','outlook.office365.com','<p>Empty\x20message</p>','html','@xcally.com','push','attachment-','includes','join','slice','textAsHtml','../../../config/logger','anonymous','gmail','isEmpty','imap.gmail.com','content','attachments','name','length','subject','contentType','filename','yahoo','now','split','<a\x20target=\x22_blank\x22\x20','YYYY-MM-DD\x20HH:mm:ss','attachment','email'];(function(_0x173654,_0x51a2a3){const _0x1a9e50=function(_0x1bdddd){while(--_0x1bdddd){_0x173654['push'](_0x173654['shift']());}};_0x1a9e50(++_0x51a2a3);}(a1155_0x51a2,0x1ba));const a1155_0x1a9e=function(_0x173654,_0x51a2a3){_0x173654=_0x173654-0x0;let _0x1a9e50=a1155_0x51a2[_0x173654];return _0x1a9e50;};const _0x58f729=a1155_0x1a9e;'use strict';const _=require(_0x58f729('0xf')),moment=require(_0x58f729('0xe')),random=require(_0x58f729('0x29')),fs=require('fs'),path=require(_0x58f729('0x13')),util=require(_0x58f729('0x10')),tnef=require(_0x58f729('0x28')),logger=require(_0x58f729('0x3b'))(_0x58f729('0xc')),config=require(_0x58f729('0x26'));function getAddress(_0x1bdddd){const _0x1eb489=_0x58f729,_0x2a771f=_[_0x1eb489('0x23')](_0x1bdddd[_0x1eb489('0x30')]);return _0x2a771f&&_0x2a771f[_0x1eb489('0x2a')]?_0x2a771f[_0x1eb489('0x2a')]:_0x1eb489('0x3c')+random['generate'](0x6)+_0x1eb489('0x34');}function getFirstName(_0x19682d){const _0x57ef5a=_0x58f729,_0x39adfc=_[_0x57ef5a('0x23')](_0x19682d[_0x57ef5a('0x30')]);if(_0x39adfc&&_0x39adfc[_0x57ef5a('0x1')]){const _0x2d130e=_0x39adfc[_0x57ef5a('0x1')][_0x57ef5a('0x8')](/\s+/);return _0x2d130e[_0x57ef5a('0x2')]?_0x2d130e[_0x57ef5a('0x39')](0x0,-0x1)[_0x57ef5a('0x38')]('\x20'):_0x39adfc[_0x57ef5a('0x1')];}return _0x57ef5a('0x1f');}function getLastName(_0x22549d){const _0x3a7766=_0x58f729,_0x573cd1=_[_0x3a7766('0x23')](_0x22549d[_0x3a7766('0x30')]);if(_0x573cd1&&_0x573cd1[_0x3a7766('0x1')]){const _0x25bfca=_0x573cd1[_0x3a7766('0x1')][_0x3a7766('0x8')](/\s+/);return _0x25bfca[_0x3a7766('0x2')]>0x1?_0x25bfca[_0x3a7766('0x2d')]():'';}return'';}function getMails(_0x2fcd9d,_0x256ab5){const _0x53d4d0=_0x58f729;let _0x836fc9='';for(let _0x3fa1c0=0x0;_0x3fa1c0<_0x256ab5[_0x53d4d0('0x30')][_0x53d4d0('0x2')];_0x3fa1c0+=0x1){_0x256ab5[_0x53d4d0('0x30')][_0x3fa1c0][_0x53d4d0('0x2a')]!==_0x2fcd9d&&(!_[_0x53d4d0('0x3e')](_0x836fc9)&&(_0x836fc9+=','),_0x836fc9+=_0x256ab5['value'][_0x3fa1c0][_0x53d4d0('0x1')]||_0x256ab5[_0x53d4d0('0x30')][_0x3fa1c0]['address']||'',_0x836fc9+='\x20<',_0x836fc9+=_0x256ab5['value'][_0x3fa1c0]['address']?_0x256ab5[_0x53d4d0('0x30')][_0x3fa1c0][_0x53d4d0('0x2a')]:'anonymous'+random['generate'](0x6)+_0x53d4d0('0x34'),_0x836fc9+='>');}return _0x836fc9;}function parseEmail(_0x2907d5,_0x3aee02,_0x1859ff){const _0x4588ff=_0x58f729;if(_0x3aee02[_0x4588ff('0x33')]){const _0x2ab055=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x2ab055[_0x4588ff('0x2f')](_0x3aee02[_0x4588ff('0x33')])){_0x3aee02[_0x4588ff('0x33')]=_0x3aee02[_0x4588ff('0x33')][_0x4588ff('0x24')](_0x2ab055,'');}_0x1859ff[_0x4588ff('0x2e')]=_0x3aee02['html'];}else _0x1859ff[_0x4588ff('0x2e')]=_0x3aee02[_0x4588ff('0x3a')];_0x1859ff['body']&&(_0x1859ff[_0x4588ff('0x2e')]=_0x1859ff['body']['replace'](/<a\s+/gi,_0x4588ff('0x9')));if(_0x3aee02['to']){_0x1859ff['message'][_0x4588ff('0x2c')]=getMails(null,_0x3aee02['to']);const _0x5ce28a=getMails(_0x2907d5[_0x4588ff('0xc')],_0x3aee02['to']);!_[_0x4588ff('0x3e')](_0x5ce28a)&&(_0x1859ff[_0x4588ff('0x1b')]['cc']+=_0x5ce28a);}if(_0x3aee02['cc']){_0x1859ff[_0x4588ff('0x1b')][_0x4588ff('0x22')]=getMails(null,_0x3aee02['cc']);const _0x221d67=getMails(_0x2907d5['email'],_0x3aee02['cc']);!_[_0x4588ff('0x3e')](_0x221d67)&&(!_[_0x4588ff('0x3e')](_0x1859ff[_0x4588ff('0x1b')]['cc'])&&(_0x1859ff['message']['cc']+=','),_0x1859ff['message']['cc']+=_0x221d67);}!_['includes'](_0x1859ff[_0x4588ff('0x1b')]['originTo'],_0x2907d5[_0x4588ff('0xc')])&&!_[_0x4588ff('0x37')](_0x1859ff['message'][_0x4588ff('0x22')],_0x2907d5[_0x4588ff('0xc')])&&(_0x1859ff[_0x4588ff('0x1b')][_0x4588ff('0x2b')]=_0x2907d5[_0x4588ff('0xc')]);if(_0x3aee02[_0x4588ff('0x0')]&&_0x3aee02[_0x4588ff('0x0')]['length']){_0x1859ff[_0x4588ff('0x1b')][_0x4588ff('0x15')]=_0x3aee02[_0x4588ff('0x0')]['length'];for(let _0x51c39f=0x0,_0x3d72ea,_0x131085,_0x37dbfd;_0x51c39f<_0x3aee02[_0x4588ff('0x0')][_0x4588ff('0x2')];_0x51c39f+=0x1){_0x3aee02['attachments'][_0x51c39f]['type']===_0x4588ff('0xb')&&(_0x37dbfd=_0x3aee02[_0x4588ff('0x0')][_0x51c39f][_0x4588ff('0x5')]||_0x4588ff('0x36')+_0x51c39f,_0x3d72ea=util[_0x4588ff('0x14')](_0x4588ff('0x20'),Date[_0x4588ff('0x7')](),_0x37dbfd),_0x131085=path['join'](config['root'],_0x4588ff('0x1e'),_0x3d72ea),fs['writeFileSync'](_0x131085,_0x3aee02[_0x4588ff('0x0')][_0x51c39f][_0x4588ff('0x40')]),_0x1859ff[_0x4588ff('0x1b')][_0x4588ff('0x0')][_0x4588ff('0x35')]({'name':_0x37dbfd,'basename':_0x3d72ea,'type':_0x3aee02['attachments'][_0x51c39f][_0x4588ff('0x4')],'filepath':_0x131085}));}}return _0x1859ff;}exports[_0x58f729('0x25')]=function(_0xfa0b14,_0x239066,_0x16089e){const _0x40fd8f=_0x58f729,_0x1e70f0={'from':getAddress(_0x239066[_0x40fd8f('0x11')]),'firstName':getFirstName(_0x239066[_0x40fd8f('0x11')]),'lastName':getLastName(_0x239066[_0x40fd8f('0x11')]),'mapKey':_0x40fd8f('0xc'),'message':{'from':getMails(_0xfa0b14[_0x40fd8f('0xc')],_0x239066[_0x40fd8f('0x11')]),'to':_0xfa0b14['email'],'cc':'','subject':_0x239066[_0x40fd8f('0x3')]||'','messageId':_0x239066[_0x40fd8f('0x17')],'inReplyTo':_0x239066[_0x40fd8f('0x1a')],'sentAt':moment(_0x239066[_0x40fd8f('0xd')])['format'](_0x40fd8f('0xa')),'attach':![],'attachments':[]}};if(!_0x239066[_0x40fd8f('0x33')]&&!_0x239066[_0x40fd8f('0x3a')]){const _0x77b439=_[_0x40fd8f('0x19')](_0x239066[_0x40fd8f('0x0')],{'contentType':'application/ms-tnef'});_0x77b439['length']?(logger[_0x40fd8f('0x16')](util[_0x40fd8f('0x14')]('Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system',_0x239066['messageId'])),tnef[_0x40fd8f('0x21')](_['first'](_0x77b439)[_0x40fd8f('0x40')],function(_0x3b06c1,_0x1b9bcc){const _0x31695c=_0x40fd8f;if(_0x1b9bcc){_0x239066[_0x31695c('0x33')]=_0x1b9bcc[_0x31695c('0x18')]||_0x31695c('0x32');if(_0x1b9bcc[_0x31695c('0x12')])for(let _0x3dc822=0x0;_0x3dc822<_0x1b9bcc[_0x31695c('0x12')][_0x31695c('0x2')];_0x3dc822++){const _0x46c9a6=_0x1b9bcc['Attachments'][_0x3dc822];_0x1e70f0[_0x31695c('0x1b')][_0x31695c('0x0')]['push']({'filename':_0x46c9a6['Title'],'content':Buffer[_0x31695c('0x11')](_0x46c9a6['Data'])});}}_0x16089e(parseEmail(_0xfa0b14,_0x239066,_0x1e70f0));})):(_0x239066['html']=_0x40fd8f('0x32'),_0x16089e(parseEmail(_0xfa0b14,_0x239066,_0x1e70f0)));}else _0x16089e(parseEmail(_0xfa0b14,_0x239066,_0x1e70f0));},exports[_0x58f729('0x27')]=function(_0x3ed996){const _0x8e49c2=_0x58f729;switch(_0x3ed996){case _0x8e49c2('0x3d'):return _0x8e49c2('0x3f');case _0x8e49c2('0x6'):return'imap.mail.yahoo.com';case _0x8e49c2('0x1c'):return _0x8e49c2('0x1d');case'outlook365':return _0x8e49c2('0x31');}return'127.0.0.1';};
\ No newline at end of file