Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / services / email / lib / utils.js
index 5146822..b74cf2d 100644 (file)
@@ -1 +1 @@
-const a1154_0x2559=['BodyHTML','address','parser','../../../config/logger','imap.mail.yahoo.com','content','replace','hotmail','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','body','gmail','writeFileSync','originTo','inReplyTo','split','join','length','email','includes','info','subject','yahoo','generate','moment','now','outlook.office365.com','<a\x20target=\x22_blank\x22\x20','slice','filter','Attachments','attachment','originCc','YYYY-MM-DD\x20HH:mm:ss','anonymous','attachments','messageId','root','push','filename','outlook365','<p>Empty\x20message</p>','parseBuffer','../../../config/environment','@xcally.com','from','format','value','pop','attachment-','lodash','head','getHost','node-tnef','imap.gmail.com','message','%s-%s','isEmpty','Anonymous','bcc','name','127.0.0.1','html','test'];(function(_0x5f0106,_0x255913){const _0x504575=function(_0x12e704){while(--_0x12e704){_0x5f0106['push'](_0x5f0106['shift']());}};_0x504575(++_0x255913);}(a1154_0x2559,0x74));const a1154_0x5045=function(_0x5f0106,_0x255913){_0x5f0106=_0x5f0106-0x0;let _0x504575=a1154_0x2559[_0x5f0106];return _0x504575;};const _0x437b06=a1154_0x5045;'use strict';const _=require(_0x437b06('0x3b')),moment=require(_0x437b06('0x21')),random=require('randomstring'),fs=require('fs'),path=require('path'),util=require('util'),tnef=require(_0x437b06('0x3e')),logger=require(_0x437b06('0xd'))(_0x437b06('0x1b')),config=require(_0x437b06('0x34'));function getAddress(_0x12e704){const _0x16af09=_0x437b06,_0x10896a=_[_0x16af09('0x3c')](_0x12e704[_0x16af09('0x38')]);return _0x10896a&&_0x10896a[_0x16af09('0xb')]?_0x10896a[_0x16af09('0xb')]:'anonymous'+random[_0x16af09('0x20')](0x6)+_0x16af09('0x35');}function getFirstName(_0x29bd49){const _0x579f3c=_0x437b06,_0x2b944b=_[_0x579f3c('0x3c')](_0x29bd49[_0x579f3c('0x38')]);if(_0x2b944b&&_0x2b944b['name']){const _0x2bbf6e=_0x2b944b[_0x579f3c('0x6')]['split'](/\s+/);return _0x2bbf6e[_0x579f3c('0x1a')]?_0x2bbf6e[_0x579f3c('0x25')](0x0,-0x1)[_0x579f3c('0x19')]('\x20'):_0x2b944b[_0x579f3c('0x6')];}return _0x579f3c('0x4');}function getLastName(_0x27c93f){const _0x102912=_0x437b06,_0x4758d5=_[_0x102912('0x3c')](_0x27c93f[_0x102912('0x38')]);if(_0x4758d5&&_0x4758d5[_0x102912('0x6')]){const _0x2bce27=_0x4758d5['name'][_0x102912('0x18')](/\s+/);return _0x2bce27[_0x102912('0x1a')]>0x1?_0x2bce27[_0x102912('0x39')]():'';}return'';}function getMails(_0x53ba44,_0x10140a){const _0x4a7977=_0x437b06;let _0x14be19='';for(let _0x45212b=0x0;_0x45212b<_0x10140a[_0x4a7977('0x38')][_0x4a7977('0x1a')];_0x45212b+=0x1){_0x10140a['value'][_0x45212b][_0x4a7977('0xb')]!==_0x53ba44&&(!_[_0x4a7977('0x3')](_0x14be19)&&(_0x14be19+=','),_0x14be19+=_0x10140a[_0x4a7977('0x38')][_0x45212b][_0x4a7977('0x6')]||_0x10140a[_0x4a7977('0x38')][_0x45212b][_0x4a7977('0xb')]||'',_0x14be19+='\x20<',_0x14be19+=_0x10140a[_0x4a7977('0x38')][_0x45212b][_0x4a7977('0xb')]?_0x10140a[_0x4a7977('0x38')][_0x45212b][_0x4a7977('0xb')]:_0x4a7977('0x2b')+random['generate'](0x6)+'@xcally.com',_0x14be19+='>');}return _0x14be19;}function parseEmail(_0x21500e,_0x4bed2e,_0x701d09){const _0x2893e9=_0x437b06;if(_0x4bed2e['html']){const _0x1fd4fb=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x1fd4fb[_0x2893e9('0x9')](_0x4bed2e['html'])){_0x4bed2e[_0x2893e9('0x8')]=_0x4bed2e[_0x2893e9('0x8')][_0x2893e9('0x10')](_0x1fd4fb,'');}_0x701d09['body']=_0x4bed2e[_0x2893e9('0x8')];}else _0x701d09[_0x2893e9('0x13')]=_0x4bed2e['textAsHtml'];_0x701d09[_0x2893e9('0x13')]&&(_0x701d09[_0x2893e9('0x13')]=_0x701d09[_0x2893e9('0x13')][_0x2893e9('0x10')](/<a\s+/gi,_0x2893e9('0x24')));if(_0x4bed2e['to']){_0x701d09['message'][_0x2893e9('0x16')]=getMails(null,_0x4bed2e['to']);const _0x4e0b3f=getMails(_0x21500e['email'],_0x4bed2e['to']);!_[_0x2893e9('0x3')](_0x4e0b3f)&&(_0x701d09[_0x2893e9('0x1')]['cc']+=_0x4e0b3f);}if(_0x4bed2e['cc']){_0x701d09[_0x2893e9('0x1')][_0x2893e9('0x29')]=getMails(null,_0x4bed2e['cc']);const _0x42bda0=getMails(_0x21500e['email'],_0x4bed2e['cc']);!_[_0x2893e9('0x3')](_0x42bda0)&&(!_[_0x2893e9('0x3')](_0x701d09['message']['cc'])&&(_0x701d09['message']['cc']+=','),_0x701d09['message']['cc']+=_0x42bda0);}!_[_0x2893e9('0x1c')](_0x701d09[_0x2893e9('0x1')][_0x2893e9('0x16')],_0x21500e[_0x2893e9('0x1b')])&&!_['includes'](_0x701d09[_0x2893e9('0x1')][_0x2893e9('0x29')],_0x21500e['email'])&&(_0x701d09[_0x2893e9('0x1')][_0x2893e9('0x5')]=_0x21500e['email']);if(_0x4bed2e[_0x2893e9('0x2c')]&&_0x4bed2e[_0x2893e9('0x2c')][_0x2893e9('0x1a')]){_0x701d09[_0x2893e9('0x1')]['attach']=_0x4bed2e[_0x2893e9('0x2c')][_0x2893e9('0x1a')];for(let _0xdc2359=0x0,_0x3cec4d,_0x2318ba,_0xf79568;_0xdc2359<_0x4bed2e['attachments']['length'];_0xdc2359+=0x1){_0x4bed2e['attachments'][_0xdc2359]['type']===_0x2893e9('0x28')&&(_0xf79568=_0x4bed2e[_0x2893e9('0x2c')][_0xdc2359][_0x2893e9('0x30')]||_0x2893e9('0x3a')+_0xdc2359,_0x3cec4d=util['format'](_0x2893e9('0x2'),Date[_0x2893e9('0x22')](),_0xf79568),_0x2318ba=path[_0x2893e9('0x19')](config[_0x2893e9('0x2e')],'files/attachments/',_0x3cec4d),fs[_0x2893e9('0x15')](_0x2318ba,_0x4bed2e[_0x2893e9('0x2c')][_0xdc2359][_0x2893e9('0xf')]),_0x701d09['message'][_0x2893e9('0x2c')][_0x2893e9('0x2f')]({'name':_0xf79568,'basename':_0x3cec4d,'type':_0x4bed2e[_0x2893e9('0x2c')][_0xdc2359]['contentType'],'filepath':_0x2318ba}));}}return _0x701d09;}exports[_0x437b06('0xc')]=function(_0xa3b743,_0x226efd,_0x320333){const _0x27c506=_0x437b06,_0x1d4efd={'from':getAddress(_0x226efd[_0x27c506('0x36')]),'firstName':getFirstName(_0x226efd[_0x27c506('0x36')]),'lastName':getLastName(_0x226efd['from']),'mapKey':'email','message':{'from':getMails(_0xa3b743[_0x27c506('0x1b')],_0x226efd[_0x27c506('0x36')]),'to':_0xa3b743['email'],'cc':'','subject':_0x226efd[_0x27c506('0x1e')]||'','messageId':_0x226efd['messageId'],'inReplyTo':_0x226efd[_0x27c506('0x17')],'sentAt':moment(_0x226efd['date'])['format'](_0x27c506('0x2a')),'attach':![],'attachments':[]}};if(!_0x226efd['html']&&!_0x226efd['textAsHtml']){const _0x84142=_[_0x27c506('0x26')](_0x226efd[_0x27c506('0x2c')],{'contentType':'application/ms-tnef'});_0x84142[_0x27c506('0x1a')]?(logger[_0x27c506('0x1d')](util[_0x27c506('0x37')](_0x27c506('0x12'),_0x226efd[_0x27c506('0x2d')])),tnef[_0x27c506('0x33')](_['first'](_0x84142)[_0x27c506('0xf')],function(_0x3cbf9f,_0x4da292){const _0x536aaf=_0x27c506;if(_0x4da292){_0x226efd[_0x536aaf('0x8')]=_0x4da292[_0x536aaf('0xa')]||'<p>Empty\x20message</p>';if(_0x4da292[_0x536aaf('0x27')])for(let _0x57f94e=0x0;_0x57f94e<_0x4da292['Attachments'][_0x536aaf('0x1a')];_0x57f94e++){const _0x14c7cf=_0x4da292['Attachments'][_0x57f94e];_0x1d4efd[_0x536aaf('0x1')]['attachments']['push']({'filename':_0x14c7cf['Title'],'content':Buffer[_0x536aaf('0x36')](_0x14c7cf['Data'])});}}_0x320333(parseEmail(_0xa3b743,_0x226efd,_0x1d4efd));})):(_0x226efd[_0x27c506('0x8')]=_0x27c506('0x32'),_0x320333(parseEmail(_0xa3b743,_0x226efd,_0x1d4efd)));}else _0x320333(parseEmail(_0xa3b743,_0x226efd,_0x1d4efd));},exports[_0x437b06('0x3d')]=function(_0x358401){const _0x4a4be8=_0x437b06;switch(_0x358401){case _0x4a4be8('0x14'):return _0x4a4be8('0x0');case _0x4a4be8('0x1f'):return _0x4a4be8('0xe');case _0x4a4be8('0x11'):return'imap-mail.outlook.com';case _0x4a4be8('0x31'):return _0x4a4be8('0x23');}return _0x4a4be8('0x7');};
\ No newline at end of file
+const a1154_0x488a=['inReplyTo','type','yahoo','split','isEmpty','originTo','attachments','@xcally.com','imap.gmail.com','parseBuffer','first','message','attachment-','gmail','%s-%s','path','attach','name','body','BodyHTML','Anonymous','subject','bcc','join','email','outlook365','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','application/ms-tnef','node-tnef','length','anonymous','writeFileSync','replace','includes','html','root','push','filename','from','hotmail','Title','../../../config/environment','content','randomstring','originCc','<p>Empty\x20message</p>','address','util','parser','127.0.0.1','head','info','messageId','filter','../../../config/logger','pop','date','Attachments','generate','format','attachment','value','outlook.office365.com','slice','Data','textAsHtml'];(function(_0x404caa,_0x488a85){const _0x2d00f7=function(_0x3dd99b){while(--_0x3dd99b){_0x404caa['push'](_0x404caa['shift']());}};_0x2d00f7(++_0x488a85);}(a1154_0x488a,0x170));const a1154_0x2d00=function(_0x404caa,_0x488a85){_0x404caa=_0x404caa-0x0;let _0x2d00f7=a1154_0x488a[_0x404caa];return _0x2d00f7;};const _0x55fd42=a1154_0x2d00;'use strict';const _=require('lodash'),moment=require('moment'),random=require(_0x55fd42('0x5')),fs=require('fs'),path=require(_0x55fd42('0x2b')),util=require(_0x55fd42('0x9')),tnef=require(_0x55fd42('0x38')),logger=require(_0x55fd42('0x10'))(_0x55fd42('0x34')),config=require(_0x55fd42('0x3'));function getAddress(_0x3dd99b){const _0x475aa0=_0x55fd42,_0x46e1eb=_['head'](_0x3dd99b[_0x475aa0('0x17')]);return _0x46e1eb&&_0x46e1eb['address']?_0x46e1eb[_0x475aa0('0x8')]:_0x475aa0('0x3a')+random['generate'](0x6)+_0x475aa0('0x23');}function getFirstName(_0x24a54f){const _0x4dd832=_0x55fd42,_0x591c10=_['head'](_0x24a54f[_0x4dd832('0x17')]);if(_0x591c10&&_0x591c10['name']){const _0x3dd363=_0x591c10['name']['split'](/\s+/);return _0x3dd363[_0x4dd832('0x39')]?_0x3dd363[_0x4dd832('0x19')](0x0,-0x1)['join']('\x20'):_0x591c10[_0x4dd832('0x2d')];}return _0x4dd832('0x30');}function getLastName(_0x1ef493){const _0xba1be5=_0x55fd42,_0x2cf124=_[_0xba1be5('0xc')](_0x1ef493[_0xba1be5('0x17')]);if(_0x2cf124&&_0x2cf124[_0xba1be5('0x2d')]){const _0x237041=_0x2cf124[_0xba1be5('0x2d')][_0xba1be5('0x1f')](/\s+/);return _0x237041[_0xba1be5('0x39')]>0x1?_0x237041[_0xba1be5('0x11')]():'';}return'';}function getMails(_0x102614,_0xaec8f9){const _0x1fdffe=_0x55fd42;let _0x40652f='';for(let _0xa174c9=0x0;_0xa174c9<_0xaec8f9[_0x1fdffe('0x17')][_0x1fdffe('0x39')];_0xa174c9+=0x1){_0xaec8f9['value'][_0xa174c9]['address']!==_0x102614&&(!_[_0x1fdffe('0x20')](_0x40652f)&&(_0x40652f+=','),_0x40652f+=_0xaec8f9['value'][_0xa174c9][_0x1fdffe('0x2d')]||_0xaec8f9[_0x1fdffe('0x17')][_0xa174c9]['address']||'',_0x40652f+='\x20<',_0x40652f+=_0xaec8f9[_0x1fdffe('0x17')][_0xa174c9][_0x1fdffe('0x8')]?_0xaec8f9[_0x1fdffe('0x17')][_0xa174c9]['address']:'anonymous'+random[_0x1fdffe('0x14')](0x6)+_0x1fdffe('0x23'),_0x40652f+='>');}return _0x40652f;}function parseEmail(_0x1b1795,_0x38b29f,_0x5e1acb){const _0x34c018=_0x55fd42;if(_0x38b29f[_0x34c018('0x3e')]){const _0x2179ca=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x2179ca['test'](_0x38b29f[_0x34c018('0x3e')])){_0x38b29f['html']=_0x38b29f['html'][_0x34c018('0x3c')](_0x2179ca,'');}_0x5e1acb[_0x34c018('0x2e')]=_0x38b29f[_0x34c018('0x3e')];}else _0x5e1acb[_0x34c018('0x2e')]=_0x38b29f[_0x34c018('0x1b')];_0x5e1acb[_0x34c018('0x2e')]&&(_0x5e1acb[_0x34c018('0x2e')]=_0x5e1acb[_0x34c018('0x2e')][_0x34c018('0x3c')](/<a\s+/gi,'<a\x20target=\x22_blank\x22\x20'));if(_0x38b29f['to']){_0x5e1acb[_0x34c018('0x27')][_0x34c018('0x21')]=getMails(null,_0x38b29f['to']);const _0x1042df=getMails(_0x1b1795[_0x34c018('0x34')],_0x38b29f['to']);!_[_0x34c018('0x20')](_0x1042df)&&(_0x5e1acb['message']['cc']+=_0x1042df);}if(_0x38b29f['cc']){_0x5e1acb['message'][_0x34c018('0x6')]=getMails(null,_0x38b29f['cc']);const _0x3f66bf=getMails(_0x1b1795[_0x34c018('0x34')],_0x38b29f['cc']);!_[_0x34c018('0x20')](_0x3f66bf)&&(!_[_0x34c018('0x20')](_0x5e1acb[_0x34c018('0x27')]['cc'])&&(_0x5e1acb[_0x34c018('0x27')]['cc']+=','),_0x5e1acb['message']['cc']+=_0x3f66bf);}!_['includes'](_0x5e1acb['message'][_0x34c018('0x21')],_0x1b1795[_0x34c018('0x34')])&&!_[_0x34c018('0x3d')](_0x5e1acb[_0x34c018('0x27')][_0x34c018('0x6')],_0x1b1795['email'])&&(_0x5e1acb['message'][_0x34c018('0x32')]=_0x1b1795['email']);if(_0x38b29f[_0x34c018('0x22')]&&_0x38b29f[_0x34c018('0x22')]['length']){_0x5e1acb['message'][_0x34c018('0x2c')]=_0x38b29f[_0x34c018('0x22')][_0x34c018('0x39')];for(let _0xeddad5=0x0,_0x432f58,_0x62cbb,_0x5c9603;_0xeddad5<_0x38b29f['attachments'][_0x34c018('0x39')];_0xeddad5+=0x1){_0x38b29f['attachments'][_0xeddad5][_0x34c018('0x1d')]===_0x34c018('0x16')&&(_0x5c9603=_0x38b29f[_0x34c018('0x22')][_0xeddad5][_0x34c018('0x41')]||_0x34c018('0x28')+_0xeddad5,_0x432f58=util['format'](_0x34c018('0x2a'),Date['now'](),_0x5c9603),_0x62cbb=path[_0x34c018('0x33')](config[_0x34c018('0x3f')],'files/attachments/',_0x432f58),fs[_0x34c018('0x3b')](_0x62cbb,_0x38b29f[_0x34c018('0x22')][_0xeddad5][_0x34c018('0x4')]),_0x5e1acb[_0x34c018('0x27')][_0x34c018('0x22')][_0x34c018('0x40')]({'name':_0x5c9603,'basename':_0x432f58,'type':_0x38b29f[_0x34c018('0x22')][_0xeddad5]['contentType'],'filepath':_0x62cbb}));}}return _0x5e1acb;}exports[_0x55fd42('0xa')]=function(_0x21e161,_0x597978,_0x5770a1){const _0x23e382=_0x55fd42,_0x489475={'from':getAddress(_0x597978[_0x23e382('0x0')]),'firstName':getFirstName(_0x597978[_0x23e382('0x0')]),'lastName':getLastName(_0x597978[_0x23e382('0x0')]),'mapKey':_0x23e382('0x34'),'message':{'from':getMails(_0x21e161[_0x23e382('0x34')],_0x597978[_0x23e382('0x0')]),'to':_0x21e161[_0x23e382('0x34')],'cc':'','subject':_0x597978[_0x23e382('0x31')]||'','messageId':_0x597978['messageId'],'inReplyTo':_0x597978[_0x23e382('0x1c')],'sentAt':moment(_0x597978[_0x23e382('0x12')])[_0x23e382('0x15')]('YYYY-MM-DD\x20HH:mm:ss'),'attach':![],'attachments':[]}};if(!_0x597978[_0x23e382('0x3e')]&&!_0x597978['textAsHtml']){const _0x380f41=_[_0x23e382('0xf')](_0x597978[_0x23e382('0x22')],{'contentType':_0x23e382('0x37')});_0x380f41['length']?(logger[_0x23e382('0xd')](util[_0x23e382('0x15')](_0x23e382('0x36'),_0x597978[_0x23e382('0xe')])),tnef[_0x23e382('0x25')](_[_0x23e382('0x26')](_0x380f41)[_0x23e382('0x4')],function(_0x591627,_0x20465f){const _0x20ce2a=_0x23e382;if(_0x20465f){_0x597978[_0x20ce2a('0x3e')]=_0x20465f[_0x20ce2a('0x2f')]||_0x20ce2a('0x7');if(_0x20465f[_0x20ce2a('0x13')])for(let _0x3a8ce4=0x0;_0x3a8ce4<_0x20465f[_0x20ce2a('0x13')][_0x20ce2a('0x39')];_0x3a8ce4++){const _0x593c3b=_0x20465f[_0x20ce2a('0x13')][_0x3a8ce4];_0x489475[_0x20ce2a('0x27')][_0x20ce2a('0x22')][_0x20ce2a('0x40')]({'filename':_0x593c3b[_0x20ce2a('0x2')],'content':Buffer[_0x20ce2a('0x0')](_0x593c3b[_0x20ce2a('0x1a')])});}}_0x5770a1(parseEmail(_0x21e161,_0x597978,_0x489475));})):(_0x597978[_0x23e382('0x3e')]='<p>Empty\x20message</p>',_0x5770a1(parseEmail(_0x21e161,_0x597978,_0x489475)));}else _0x5770a1(parseEmail(_0x21e161,_0x597978,_0x489475));},exports['getHost']=function(_0x165633){const _0x33bdea=_0x55fd42;switch(_0x165633){case _0x33bdea('0x29'):return _0x33bdea('0x24');case _0x33bdea('0x1e'):return'imap.mail.yahoo.com';case _0x33bdea('0x1'):return'imap-mail.outlook.com';case _0x33bdea('0x35'):return _0x33bdea('0x18');}return _0x33bdea('0xb');};
\ No newline at end of file