Built motion from commit 973e3e332e1c8e2f84c4b0cd2e5af794131724f5. Version 3.0.0...
[motion-next.git] / server / services / email / lib / utils.js
index 28a3972..2943307 100644 (file)
@@ -1 +1 @@
-const a1154_0x2e60=['address','YYYY-MM-DD\x20HH:mm:ss','parser','first','yahoo','info','Data','Anonymous','originCc','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','attach','outlook.office365.com','path','split','imap-mail.outlook.com','isEmpty','files/attachments/','util','../../../config/logger','bcc','Title','%s-%s','application/ms-tnef','parseBuffer','slice','../../../config/environment','imap.mail.yahoo.com','moment','join','attachments','originTo','BodyHTML','inReplyTo','length','<p>Empty\x20message</p>','replace','root','includes','type','outlook365','writeFileSync','filter','format','getHost','head','message','<a\x20target=\x22_blank\x22\x20','from','value','@xcally.com','generate','html','body','name','anonymous','node-tnef','content','textAsHtml','subject','date','gmail','attachment-','email','now','messageId','push'];(function(_0x241542,_0x2e609b){const _0x4b4df7=function(_0x397e6d){while(--_0x397e6d){_0x241542['push'](_0x241542['shift']());}};_0x4b4df7(++_0x2e609b);}(a1154_0x2e60,0x137));const a1154_0x4b4d=function(_0x241542,_0x2e609b){_0x241542=_0x241542-0x0;let _0x4b4df7=a1154_0x2e60[_0x241542];return _0x4b4df7;};const _0x340f6c=a1154_0x4b4d;'use strict';const _=require('lodash'),moment=require(_0x340f6c('0x2e')),random=require('randomstring'),fs=require('fs'),path=require(_0x340f6c('0x1f')),util=require(_0x340f6c('0x24')),tnef=require(_0x340f6c('0x8')),logger=require(_0x340f6c('0x25'))(_0x340f6c('0xf')),config=require(_0x340f6c('0x2c'));function getAddress(_0x397e6d){const _0x69adae=_0x340f6c,_0x50a732=_[_0x69adae('0x3f')](_0x397e6d[_0x69adae('0x1')]);return _0x50a732&&_0x50a732[_0x69adae('0x13')]?_0x50a732[_0x69adae('0x13')]:'anonymous'+random[_0x69adae('0x3')](0x6)+_0x69adae('0x2');}function getFirstName(_0x57ceeb){const _0xf8532c=_0x340f6c,_0x958eb6=_[_0xf8532c('0x3f')](_0x57ceeb['value']);if(_0x958eb6&&_0x958eb6[_0xf8532c('0x6')]){const _0x5e6957=_0x958eb6[_0xf8532c('0x6')][_0xf8532c('0x20')](/\s+/);return _0x5e6957[_0xf8532c('0x34')]?_0x5e6957[_0xf8532c('0x2b')](0x0,-0x1)['join']('\x20'):_0x958eb6['name'];}return _0xf8532c('0x1a');}function getLastName(_0x2e4211){const _0x55b512=_0x340f6c,_0x2bca51=_[_0x55b512('0x3f')](_0x2e4211[_0x55b512('0x1')]);if(_0x2bca51&&_0x2bca51[_0x55b512('0x6')]){const _0x4224ec=_0x2bca51['name']['split'](/\s+/);return _0x4224ec[_0x55b512('0x34')]>0x1?_0x4224ec['pop']():'';}return'';}function getMails(_0x37739f,_0x10cbf0){const _0x2de7d3=_0x340f6c;let _0x13969a='';for(let _0xfe5f22=0x0;_0xfe5f22<_0x10cbf0['value'][_0x2de7d3('0x34')];_0xfe5f22+=0x1){_0x10cbf0[_0x2de7d3('0x1')][_0xfe5f22]['address']!==_0x37739f&&(!_[_0x2de7d3('0x22')](_0x13969a)&&(_0x13969a+=','),_0x13969a+=_0x10cbf0[_0x2de7d3('0x1')][_0xfe5f22][_0x2de7d3('0x6')]||_0x10cbf0[_0x2de7d3('0x1')][_0xfe5f22][_0x2de7d3('0x13')]||'',_0x13969a+='\x20<',_0x13969a+=_0x10cbf0[_0x2de7d3('0x1')][_0xfe5f22][_0x2de7d3('0x13')]?_0x10cbf0[_0x2de7d3('0x1')][_0xfe5f22]['address']:_0x2de7d3('0x7')+random['generate'](0x6)+_0x2de7d3('0x2'),_0x13969a+='>');}return _0x13969a;}function parseEmail(_0x5ce760,_0x5df3bf,_0x5cbd6a){const _0x33b761=_0x340f6c;if(_0x5df3bf[_0x33b761('0x4')]){const _0x2fb077=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x2fb077['test'](_0x5df3bf[_0x33b761('0x4')])){_0x5df3bf[_0x33b761('0x4')]=_0x5df3bf[_0x33b761('0x4')]['replace'](_0x2fb077,'');}_0x5cbd6a[_0x33b761('0x5')]=_0x5df3bf[_0x33b761('0x4')];}else _0x5cbd6a['body']=_0x5df3bf[_0x33b761('0xa')];_0x5cbd6a['body']&&(_0x5cbd6a[_0x33b761('0x5')]=_0x5cbd6a[_0x33b761('0x5')][_0x33b761('0x36')](/<a\s+/gi,_0x33b761('0x41')));if(_0x5df3bf['to']){_0x5cbd6a[_0x33b761('0x40')][_0x33b761('0x31')]=getMails(null,_0x5df3bf['to']);const _0xe7f9e7=getMails(_0x5ce760['email'],_0x5df3bf['to']);!_[_0x33b761('0x22')](_0xe7f9e7)&&(_0x5cbd6a[_0x33b761('0x40')]['cc']+=_0xe7f9e7);}if(_0x5df3bf['cc']){_0x5cbd6a[_0x33b761('0x40')]['originCc']=getMails(null,_0x5df3bf['cc']);const _0x5b332a=getMails(_0x5ce760[_0x33b761('0xf')],_0x5df3bf['cc']);!_['isEmpty'](_0x5b332a)&&(!_[_0x33b761('0x22')](_0x5cbd6a['message']['cc'])&&(_0x5cbd6a['message']['cc']+=','),_0x5cbd6a['message']['cc']+=_0x5b332a);}!_[_0x33b761('0x38')](_0x5cbd6a['message'][_0x33b761('0x31')],_0x5ce760['email'])&&!_['includes'](_0x5cbd6a[_0x33b761('0x40')][_0x33b761('0x1b')],_0x5ce760[_0x33b761('0xf')])&&(_0x5cbd6a[_0x33b761('0x40')][_0x33b761('0x26')]=_0x5ce760[_0x33b761('0xf')]);if(_0x5df3bf[_0x33b761('0x30')]&&_0x5df3bf[_0x33b761('0x30')][_0x33b761('0x34')]){_0x5cbd6a[_0x33b761('0x40')][_0x33b761('0x1d')]=_0x5df3bf[_0x33b761('0x30')]['length'];for(let _0x385e05=0x0,_0x36a9a8,_0x3e7794,_0x54457b;_0x385e05<_0x5df3bf['attachments']['length'];_0x385e05+=0x1){_0x5df3bf[_0x33b761('0x30')][_0x385e05][_0x33b761('0x39')]==='attachment'&&(_0x54457b=_0x5df3bf[_0x33b761('0x30')][_0x385e05]['filename']||_0x33b761('0xe')+_0x385e05,_0x36a9a8=util[_0x33b761('0x3d')](_0x33b761('0x28'),Date[_0x33b761('0x10')](),_0x54457b),_0x3e7794=path[_0x33b761('0x2f')](config[_0x33b761('0x37')],_0x33b761('0x23'),_0x36a9a8),fs[_0x33b761('0x3b')](_0x3e7794,_0x5df3bf[_0x33b761('0x30')][_0x385e05][_0x33b761('0x9')]),_0x5cbd6a[_0x33b761('0x40')][_0x33b761('0x30')][_0x33b761('0x12')]({'name':_0x54457b,'basename':_0x36a9a8,'type':_0x5df3bf[_0x33b761('0x30')][_0x385e05]['contentType'],'filepath':_0x3e7794}));}}return _0x5cbd6a;}exports[_0x340f6c('0x15')]=function(_0x8d506e,_0x56fe7c,_0x4c42e1){const _0x14322d=_0x340f6c,_0x3401de={'from':getAddress(_0x56fe7c[_0x14322d('0x0')]),'firstName':getFirstName(_0x56fe7c['from']),'lastName':getLastName(_0x56fe7c[_0x14322d('0x0')]),'mapKey':'email','message':{'from':getMails(_0x8d506e[_0x14322d('0xf')],_0x56fe7c[_0x14322d('0x0')]),'to':_0x8d506e[_0x14322d('0xf')],'cc':'','subject':_0x56fe7c[_0x14322d('0xb')]||'','messageId':_0x56fe7c[_0x14322d('0x11')],'inReplyTo':_0x56fe7c[_0x14322d('0x33')],'sentAt':moment(_0x56fe7c[_0x14322d('0xc')])[_0x14322d('0x3d')](_0x14322d('0x14')),'attach':![],'attachments':[]}};if(!_0x56fe7c[_0x14322d('0x4')]&&!_0x56fe7c[_0x14322d('0xa')]){const _0x5a9d4d=_[_0x14322d('0x3c')](_0x56fe7c[_0x14322d('0x30')],{'contentType':_0x14322d('0x29')});_0x5a9d4d['length']?(logger[_0x14322d('0x18')](util[_0x14322d('0x3d')](_0x14322d('0x1c'),_0x56fe7c['messageId'])),tnef[_0x14322d('0x2a')](_[_0x14322d('0x16')](_0x5a9d4d)[_0x14322d('0x9')],function(_0x30e157,_0x3e918f){const _0xf16acb=_0x14322d;if(_0x3e918f){_0x56fe7c['html']=_0x3e918f[_0xf16acb('0x32')]||_0xf16acb('0x35');if(_0x3e918f['Attachments'])for(let _0x32b9a2=0x0;_0x32b9a2<_0x3e918f['Attachments'][_0xf16acb('0x34')];_0x32b9a2++){const _0x3cb879=_0x3e918f['Attachments'][_0x32b9a2];_0x3401de['message'][_0xf16acb('0x30')]['push']({'filename':_0x3cb879[_0xf16acb('0x27')],'content':Buffer[_0xf16acb('0x0')](_0x3cb879[_0xf16acb('0x19')])});}}_0x4c42e1(parseEmail(_0x8d506e,_0x56fe7c,_0x3401de));})):(_0x56fe7c[_0x14322d('0x4')]=_0x14322d('0x35'),_0x4c42e1(parseEmail(_0x8d506e,_0x56fe7c,_0x3401de)));}else _0x4c42e1(parseEmail(_0x8d506e,_0x56fe7c,_0x3401de));},exports[_0x340f6c('0x3e')]=function(_0x1cccfd){const _0x4173e0=_0x340f6c;switch(_0x1cccfd){case _0x4173e0('0xd'):return'imap.gmail.com';case _0x4173e0('0x17'):return _0x4173e0('0x2d');case'hotmail':return _0x4173e0('0x21');case _0x4173e0('0x3a'):return _0x4173e0('0x1e');}return'127.0.0.1';};
\ No newline at end of file
+const a1155_0x4c7e=['node-tnef','join','generate','writeFileSync','length','Title','head','bcc','parser','replace','textAsHtml','BodyHTML','YYYY-MM-DD\x20HH:mm:ss','includes','isEmpty','util','email','path','date','getHost','imap-mail.outlook.com','attachments','Attachments','now','<p>Empty\x20message</p>','message','from','info','split','messageId','inReplyTo','push','Data','imap.mail.yahoo.com','test','gmail','<a\x20target=\x22_blank\x22\x20','address','randomstring','type','lodash','html','contentType','format','files/attachments/','anonymous','attachment-','value','moment','outlook365','@xcally.com','application/ms-tnef','imap.gmail.com','name','originCc','slice','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','originTo','body','outlook.office365.com'];(function(_0x1d50c2,_0x4c7e1e){const _0x14f55c=function(_0x213f1a){while(--_0x213f1a){_0x1d50c2['push'](_0x1d50c2['shift']());}};_0x14f55c(++_0x4c7e1e);}(a1155_0x4c7e,0x1df));const a1155_0x14f5=function(_0x1d50c2,_0x4c7e1e){_0x1d50c2=_0x1d50c2-0x0;let _0x14f55c=a1155_0x4c7e[_0x1d50c2];return _0x14f55c;};const _0x320b35=a1155_0x14f5;'use strict';const _=require(_0x320b35('0x29')),moment=require(_0x320b35('0x31')),random=require(_0x320b35('0x27')),fs=require('fs'),path=require(_0x320b35('0x12')),util=require(_0x320b35('0x10')),tnef=require(_0x320b35('0x1')),logger=require('../../../config/logger')('email'),config=require('../../../config/environment');function getAddress(_0x213f1a){const _0x5335c2=_0x320b35,_0x22820a=_['head'](_0x213f1a[_0x5335c2('0x30')]);return _0x22820a&&_0x22820a[_0x5335c2('0x26')]?_0x22820a[_0x5335c2('0x26')]:_0x5335c2('0x2e')+random['generate'](0x6)+'@xcally.com';}function getFirstName(_0x3707a9){const _0x17db57=_0x320b35,_0x316efa=_[_0x17db57('0x7')](_0x3707a9[_0x17db57('0x30')]);if(_0x316efa&&_0x316efa[_0x17db57('0x36')]){const _0x5ebc95=_0x316efa[_0x17db57('0x36')][_0x17db57('0x1d')](/\s+/);return _0x5ebc95[_0x17db57('0x5')]?_0x5ebc95[_0x17db57('0x38')](0x0,-0x1)['join']('\x20'):_0x316efa[_0x17db57('0x36')];}return'Anonymous';}function getLastName(_0x3ca345){const _0x4c228a=_0x320b35,_0x4b8fd1=_[_0x4c228a('0x7')](_0x3ca345[_0x4c228a('0x30')]);if(_0x4b8fd1&&_0x4b8fd1[_0x4c228a('0x36')]){const _0x1504ef=_0x4b8fd1['name']['split'](/\s+/);return _0x1504ef[_0x4c228a('0x5')]>0x1?_0x1504ef['pop']():'';}return'';}function getMails(_0x130d88,_0x5e8dd1){const _0x227a11=_0x320b35;let _0x4c8701='';for(let _0x1305f6=0x0;_0x1305f6<_0x5e8dd1[_0x227a11('0x30')][_0x227a11('0x5')];_0x1305f6+=0x1){_0x5e8dd1[_0x227a11('0x30')][_0x1305f6][_0x227a11('0x26')]!==_0x130d88&&(!_['isEmpty'](_0x4c8701)&&(_0x4c8701+=','),_0x4c8701+=_0x5e8dd1[_0x227a11('0x30')][_0x1305f6][_0x227a11('0x36')]||_0x5e8dd1[_0x227a11('0x30')][_0x1305f6][_0x227a11('0x26')]||'',_0x4c8701+='\x20<',_0x4c8701+=_0x5e8dd1[_0x227a11('0x30')][_0x1305f6][_0x227a11('0x26')]?_0x5e8dd1[_0x227a11('0x30')][_0x1305f6][_0x227a11('0x26')]:'anonymous'+random[_0x227a11('0x3')](0x6)+_0x227a11('0x33'),_0x4c8701+='>');}return _0x4c8701;}function parseEmail(_0x38a3b1,_0x42f88b,_0x199f4f){const _0xd5fbc0=_0x320b35;if(_0x42f88b[_0xd5fbc0('0x2a')]){const _0x2b66c3=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x2b66c3[_0xd5fbc0('0x23')](_0x42f88b['html'])){_0x42f88b['html']=_0x42f88b['html'][_0xd5fbc0('0xa')](_0x2b66c3,'');}_0x199f4f[_0xd5fbc0('0x3b')]=_0x42f88b[_0xd5fbc0('0x2a')];}else _0x199f4f[_0xd5fbc0('0x3b')]=_0x42f88b[_0xd5fbc0('0xb')];_0x199f4f[_0xd5fbc0('0x3b')]&&(_0x199f4f[_0xd5fbc0('0x3b')]=_0x199f4f[_0xd5fbc0('0x3b')][_0xd5fbc0('0xa')](/<a\s+/gi,_0xd5fbc0('0x25')));if(_0x42f88b['to']){_0x199f4f['message'][_0xd5fbc0('0x3a')]=getMails(null,_0x42f88b['to']);const _0xb800d3=getMails(_0x38a3b1['email'],_0x42f88b['to']);!_['isEmpty'](_0xb800d3)&&(_0x199f4f[_0xd5fbc0('0x1a')]['cc']+=_0xb800d3);}if(_0x42f88b['cc']){_0x199f4f[_0xd5fbc0('0x1a')][_0xd5fbc0('0x37')]=getMails(null,_0x42f88b['cc']);const _0x365745=getMails(_0x38a3b1[_0xd5fbc0('0x11')],_0x42f88b['cc']);!_[_0xd5fbc0('0xf')](_0x365745)&&(!_[_0xd5fbc0('0xf')](_0x199f4f[_0xd5fbc0('0x1a')]['cc'])&&(_0x199f4f[_0xd5fbc0('0x1a')]['cc']+=','),_0x199f4f[_0xd5fbc0('0x1a')]['cc']+=_0x365745);}!_[_0xd5fbc0('0xe')](_0x199f4f['message'][_0xd5fbc0('0x3a')],_0x38a3b1[_0xd5fbc0('0x11')])&&!_['includes'](_0x199f4f[_0xd5fbc0('0x1a')][_0xd5fbc0('0x37')],_0x38a3b1[_0xd5fbc0('0x11')])&&(_0x199f4f[_0xd5fbc0('0x1a')][_0xd5fbc0('0x8')]=_0x38a3b1[_0xd5fbc0('0x11')]);if(_0x42f88b[_0xd5fbc0('0x16')]&&_0x42f88b[_0xd5fbc0('0x16')][_0xd5fbc0('0x5')]){_0x199f4f[_0xd5fbc0('0x1a')]['attach']=_0x42f88b['attachments']['length'];for(let _0x181d66=0x0,_0x253233,_0x3b3a2f,_0x1c132c;_0x181d66<_0x42f88b[_0xd5fbc0('0x16')][_0xd5fbc0('0x5')];_0x181d66+=0x1){_0x42f88b[_0xd5fbc0('0x16')][_0x181d66][_0xd5fbc0('0x28')]==='attachment'&&(_0x1c132c=_0x42f88b[_0xd5fbc0('0x16')][_0x181d66]['filename']||_0xd5fbc0('0x2f')+_0x181d66,_0x253233=util[_0xd5fbc0('0x2c')]('%s-%s',Date[_0xd5fbc0('0x18')](),_0x1c132c),_0x3b3a2f=path[_0xd5fbc0('0x2')](config['root'],_0xd5fbc0('0x2d'),_0x253233),fs[_0xd5fbc0('0x4')](_0x3b3a2f,_0x42f88b[_0xd5fbc0('0x16')][_0x181d66]['content']),_0x199f4f['message'][_0xd5fbc0('0x16')][_0xd5fbc0('0x20')]({'name':_0x1c132c,'basename':_0x253233,'type':_0x42f88b['attachments'][_0x181d66][_0xd5fbc0('0x2b')],'filepath':_0x3b3a2f}));}}return _0x199f4f;}exports[_0x320b35('0x9')]=function(_0x297907,_0x4421ed,_0x2245bd){const _0x28f721=_0x320b35,_0x24f607={'from':getAddress(_0x4421ed['from']),'firstName':getFirstName(_0x4421ed[_0x28f721('0x1b')]),'lastName':getLastName(_0x4421ed['from']),'mapKey':_0x28f721('0x11'),'message':{'from':getMails(_0x297907[_0x28f721('0x11')],_0x4421ed['from']),'to':_0x297907['email'],'cc':'','subject':_0x4421ed['subject']||'','messageId':_0x4421ed[_0x28f721('0x1e')],'inReplyTo':_0x4421ed[_0x28f721('0x1f')],'sentAt':moment(_0x4421ed[_0x28f721('0x13')])[_0x28f721('0x2c')](_0x28f721('0xd')),'attach':![],'attachments':[]}};if(!_0x4421ed['html']&&!_0x4421ed[_0x28f721('0xb')]){const _0x4a2d2b=_['filter'](_0x4421ed['attachments'],{'contentType':_0x28f721('0x34')});_0x4a2d2b['length']?(logger[_0x28f721('0x1c')](util[_0x28f721('0x2c')](_0x28f721('0x39'),_0x4421ed['messageId'])),tnef['parseBuffer'](_['first'](_0x4a2d2b)['content'],function(_0x1f1fe8,_0x91b705){const _0x794c01=_0x28f721;if(_0x91b705){_0x4421ed[_0x794c01('0x2a')]=_0x91b705[_0x794c01('0xc')]||_0x794c01('0x19');if(_0x91b705[_0x794c01('0x17')])for(let _0x4ff9ef=0x0;_0x4ff9ef<_0x91b705[_0x794c01('0x17')][_0x794c01('0x5')];_0x4ff9ef++){const _0x22c21a=_0x91b705[_0x794c01('0x17')][_0x4ff9ef];_0x24f607[_0x794c01('0x1a')]['attachments'][_0x794c01('0x20')]({'filename':_0x22c21a[_0x794c01('0x6')],'content':Buffer[_0x794c01('0x1b')](_0x22c21a[_0x794c01('0x21')])});}}_0x2245bd(parseEmail(_0x297907,_0x4421ed,_0x24f607));})):(_0x4421ed[_0x28f721('0x2a')]=_0x28f721('0x19'),_0x2245bd(parseEmail(_0x297907,_0x4421ed,_0x24f607)));}else _0x2245bd(parseEmail(_0x297907,_0x4421ed,_0x24f607));},exports[_0x320b35('0x14')]=function(_0x4a5180){const _0xbc8507=_0x320b35;switch(_0x4a5180){case _0xbc8507('0x24'):return _0xbc8507('0x35');case'yahoo':return _0xbc8507('0x22');case'hotmail':return _0xbc8507('0x15');case _0xbc8507('0x32'):return _0xbc8507('0x0');}return'127.0.0.1';};
\ No newline at end of file