Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / services / email / lib / utils.js
index e6a1e2e..44c3730 100644 (file)
@@ -1 +1 @@
-const a1319_0x1d8e=['util','isEmpty','name','address','imap.gmail.com','inReplyTo','%s-%s','imap-mail.outlook.com','email','textAsHtml','test','@xcally.com','split','application/ms-tnef','path','contentType','attach','parseBuffer','body','value','originCc','bcc','length','Data','type','replace','content','messageId','head','anonymous','yahoo','imap.mail.yahoo.com','writeFileSync','message','originTo','now','127.0.0.1','from','includes','../../../config/logger','outlook365','randomstring','hotmail','info','<a\x20target=\x22_blank\x22\x20','filename','YYYY-MM-DD\x20HH:mm:ss','html','<p>Empty\x20message</p>','Title','attachment-','lodash','join','attachments','Anonymous','format','../../../config/environment','generate','filter','node-tnef','files/attachments/','getHost'];(function(_0x2fd323,_0x4c34df){const _0x1d8e92=function(_0x52e33a){while(--_0x52e33a){_0x2fd323['push'](_0x2fd323['shift']());}};_0x1d8e92(++_0x4c34df);}(a1319_0x1d8e,0x1a7));const a1319_0x52e3=function(_0x2fd323,_0x4c34df){_0x2fd323=_0x2fd323-0x1f4;let _0x1d8e92=a1319_0x1d8e[_0x2fd323];return _0x1d8e92;};const a1319_0x15b78f=a1319_0x52e3;'use strict';const _=require(a1319_0x15b78f(0x1f4)),moment=require('moment'),random=require(a1319_0x15b78f(0x228)),fs=require('fs'),path=require(a1319_0x15b78f(0x20d)),util=require(a1319_0x15b78f(0x1ff)),tnef=require(a1319_0x15b78f(0x1fc)),logger=require(a1319_0x15b78f(0x226))('email'),config=require(a1319_0x15b78f(0x1f9));function getAddress(_0x22323a){const _0x4f6e22=a1319_0x15b78f,_0x2615a7=_[_0x4f6e22(0x21b)](_0x22323a['value']);return _0x2615a7&&_0x2615a7[_0x4f6e22(0x202)]?_0x2615a7[_0x4f6e22(0x202)]:_0x4f6e22(0x21c)+random['generate'](0x6)+_0x4f6e22(0x20a);}function getFirstName(_0x352f7e){const _0x369d1e=a1319_0x15b78f,_0x40b720=_[_0x369d1e(0x21b)](_0x352f7e[_0x369d1e(0x212)]);if(_0x40b720&&_0x40b720[_0x369d1e(0x201)]){const _0x26bab6=_0x40b720[_0x369d1e(0x201)][_0x369d1e(0x20b)](/\s+/);return _0x26bab6['length']?_0x26bab6['slice'](0x0,-0x1)['join']('\x20'):_0x40b720[_0x369d1e(0x201)];}return _0x369d1e(0x1f7);}function getLastName(_0x48dc31){const _0x172155=a1319_0x15b78f,_0x429c9b=_[_0x172155(0x21b)](_0x48dc31[_0x172155(0x212)]);if(_0x429c9b&&_0x429c9b[_0x172155(0x201)]){const _0x4fba2d=_0x429c9b[_0x172155(0x201)][_0x172155(0x20b)](/\s+/);return _0x4fba2d[_0x172155(0x215)]>0x1?_0x4fba2d['pop']():'';}return'';}function getMails(_0xc9dac0,_0x394c6b){const _0x3ad938=a1319_0x15b78f;let _0x2136b3='';for(let _0x418b5d=0x0;_0x418b5d<_0x394c6b[_0x3ad938(0x212)][_0x3ad938(0x215)];_0x418b5d+=0x1){_0x394c6b[_0x3ad938(0x212)][_0x418b5d][_0x3ad938(0x202)]!==_0xc9dac0&&(!_['isEmpty'](_0x2136b3)&&(_0x2136b3+=','),_0x2136b3+=_0x394c6b['value'][_0x418b5d]['name']||_0x394c6b[_0x3ad938(0x212)][_0x418b5d]['address']||'',_0x2136b3+='\x20<',_0x2136b3+=_0x394c6b[_0x3ad938(0x212)][_0x418b5d][_0x3ad938(0x202)]?_0x394c6b[_0x3ad938(0x212)][_0x418b5d][_0x3ad938(0x202)]:_0x3ad938(0x21c)+random[_0x3ad938(0x1fa)](0x6)+_0x3ad938(0x20a),_0x2136b3+='>');}return _0x2136b3;}function parseEmail(_0x20340f,_0x550bad,_0x572721){const _0x1f8d05=a1319_0x15b78f;if(_0x550bad[_0x1f8d05(0x22e)]){const _0x3dc594=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x3dc594[_0x1f8d05(0x209)](_0x550bad[_0x1f8d05(0x22e)])){_0x550bad[_0x1f8d05(0x22e)]=_0x550bad['html'][_0x1f8d05(0x218)](_0x3dc594,'');}_0x572721[_0x1f8d05(0x211)]=_0x550bad[_0x1f8d05(0x22e)];}else _0x572721[_0x1f8d05(0x211)]=_0x550bad[_0x1f8d05(0x208)];_0x572721[_0x1f8d05(0x211)]&&(_0x572721[_0x1f8d05(0x211)]=_0x572721[_0x1f8d05(0x211)][_0x1f8d05(0x218)](/<a\s+/gi,_0x1f8d05(0x22b)));if(_0x550bad['to']){_0x572721[_0x1f8d05(0x220)][_0x1f8d05(0x221)]=getMails(null,_0x550bad['to']);const _0x21b9ec=getMails(_0x20340f[_0x1f8d05(0x207)],_0x550bad['to']);!_[_0x1f8d05(0x200)](_0x21b9ec)&&(_0x572721[_0x1f8d05(0x220)]['cc']+=_0x21b9ec);}if(_0x550bad['cc']){_0x572721['message']['originCc']=getMails(null,_0x550bad['cc']);const _0x557541=getMails(_0x20340f['email'],_0x550bad['cc']);!_[_0x1f8d05(0x200)](_0x557541)&&(!_[_0x1f8d05(0x200)](_0x572721['message']['cc'])&&(_0x572721[_0x1f8d05(0x220)]['cc']+=','),_0x572721[_0x1f8d05(0x220)]['cc']+=_0x557541);}!_['includes'](_0x572721[_0x1f8d05(0x220)]['originTo'],_0x20340f[_0x1f8d05(0x207)])&&!_[_0x1f8d05(0x225)](_0x572721[_0x1f8d05(0x220)][_0x1f8d05(0x213)],_0x20340f[_0x1f8d05(0x207)])&&(_0x572721['message'][_0x1f8d05(0x214)]=_0x20340f[_0x1f8d05(0x207)]);if(_0x550bad[_0x1f8d05(0x1f6)]&&_0x550bad[_0x1f8d05(0x1f6)][_0x1f8d05(0x215)]){_0x572721[_0x1f8d05(0x220)][_0x1f8d05(0x20f)]=_0x550bad['attachments'][_0x1f8d05(0x215)];for(let _0xb5a410=0x0,_0x1e9d72,_0x395fd8,_0x2b291d;_0xb5a410<_0x550bad[_0x1f8d05(0x1f6)][_0x1f8d05(0x215)];_0xb5a410+=0x1){_0x550bad['attachments'][_0xb5a410][_0x1f8d05(0x217)]==='attachment'&&(_0x2b291d=_0x550bad['attachments'][_0xb5a410][_0x1f8d05(0x22c)]||_0x1f8d05(0x231)+_0xb5a410,_0x1e9d72=util[_0x1f8d05(0x1f8)](_0x1f8d05(0x205),Date[_0x1f8d05(0x222)](),_0x2b291d),_0x395fd8=path[_0x1f8d05(0x1f5)](config['root'],_0x1f8d05(0x1fd),_0x1e9d72),fs[_0x1f8d05(0x21f)](_0x395fd8,_0x550bad[_0x1f8d05(0x1f6)][_0xb5a410][_0x1f8d05(0x219)]),_0x572721[_0x1f8d05(0x220)][_0x1f8d05(0x1f6)]['push']({'name':_0x2b291d,'basename':_0x1e9d72,'type':_0x550bad[_0x1f8d05(0x1f6)][_0xb5a410][_0x1f8d05(0x20e)],'filepath':_0x395fd8}));}}return _0x572721;}exports['parser']=function(_0x521c6b,_0x369869,_0x2ccf2a){const _0x3f60eb=a1319_0x15b78f,_0x1b84c0={'from':getAddress(_0x369869[_0x3f60eb(0x224)]),'firstName':getFirstName(_0x369869[_0x3f60eb(0x224)]),'lastName':getLastName(_0x369869['from']),'mapKey':_0x3f60eb(0x207),'message':{'from':getMails(_0x521c6b[_0x3f60eb(0x207)],_0x369869[_0x3f60eb(0x224)]),'to':_0x521c6b['email'],'cc':'','subject':_0x369869['subject']||'','messageId':_0x369869[_0x3f60eb(0x21a)],'inReplyTo':_0x369869[_0x3f60eb(0x204)],'sentAt':moment(_0x369869['date'])[_0x3f60eb(0x1f8)](_0x3f60eb(0x22d)),'attach':![],'attachments':[]}};if(!_0x369869[_0x3f60eb(0x22e)]&&!_0x369869[_0x3f60eb(0x208)]){const _0x5d3a6f=_[_0x3f60eb(0x1fb)](_0x369869[_0x3f60eb(0x1f6)],{'contentType':_0x3f60eb(0x20c)});_0x5d3a6f['length']?(logger[_0x3f60eb(0x22a)](util[_0x3f60eb(0x1f8)]('Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system',_0x369869['messageId'])),tnef[_0x3f60eb(0x210)](_['first'](_0x5d3a6f)[_0x3f60eb(0x219)],function(_0x1bf755,_0x1ea349){const _0x3e1dda=_0x3f60eb;if(_0x1ea349){_0x369869['html']=_0x1ea349['BodyHTML']||_0x3e1dda(0x22f);if(_0x1ea349['Attachments'])for(let _0x534dac=0x0;_0x534dac<_0x1ea349['Attachments'][_0x3e1dda(0x215)];_0x534dac++){const _0x20a1ab=_0x1ea349['Attachments'][_0x534dac];_0x1b84c0[_0x3e1dda(0x220)][_0x3e1dda(0x1f6)]['push']({'filename':_0x20a1ab[_0x3e1dda(0x230)],'content':Buffer[_0x3e1dda(0x224)](_0x20a1ab[_0x3e1dda(0x216)])});}}_0x2ccf2a(parseEmail(_0x521c6b,_0x369869,_0x1b84c0));})):(_0x369869['html']=_0x3f60eb(0x22f),_0x2ccf2a(parseEmail(_0x521c6b,_0x369869,_0x1b84c0)));}else _0x2ccf2a(parseEmail(_0x521c6b,_0x369869,_0x1b84c0));},exports[a1319_0x15b78f(0x1fe)]=function(_0x47e474){const _0x4444fc=a1319_0x15b78f;switch(_0x47e474){case'gmail':return _0x4444fc(0x203);case _0x4444fc(0x21d):return _0x4444fc(0x21e);case _0x4444fc(0x229):return _0x4444fc(0x206);case _0x4444fc(0x227):return'outlook.office365.com';}return _0x4444fc(0x223);};
\ No newline at end of file
+const a1323_0x29b2=['application/ms-tnef','info','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','message','node-tnef','outlook365','parseBuffer','getHost','messageId','value','gmail','generate','attachment','content','files/attachments/','BodyHTML','originCc','contentType','originTo','html','lodash','imap-mail.outlook.com','imap.gmail.com','@xcally.com','join','format','randomstring','type','textAsHtml','<p>Empty\x20message</p>','attach','isEmpty','parser','pop','moment','subject','anonymous','from','../../../config/environment','filter','now','address','email','replace','test','Title','attachments','root','Attachments','length','filename','attachment-','imap.mail.yahoo.com','inReplyTo','includes','bcc','<a\x20target=\x22_blank\x22\x20','Anonymous','body','slice','%s-%s','outlook.office365.com','head','Data','first','split','name','util'];(function(_0x33648d,_0x4022a6){const _0x29b232=function(_0x1696c7){while(--_0x1696c7){_0x33648d['push'](_0x33648d['shift']());}};_0x29b232(++_0x4022a6);}(a1323_0x29b2,0x1ee));const a1323_0x1696=function(_0x33648d,_0x4022a6){_0x33648d=_0x33648d-0x6a;let _0x29b232=a1323_0x29b2[_0x33648d];return _0x29b232;};const a1323_0x57336e=a1323_0x1696;'use strict';const _=require(a1323_0x57336e(0x6c)),moment=require(a1323_0x57336e(0x7a)),random=require(a1323_0x57336e(0x72)),fs=require('fs'),path=require('path'),util=require(a1323_0x57336e(0x9b)),tnef=require(a1323_0x57336e(0xa0)),logger=require('../../../config/logger')(a1323_0x57336e(0x82)),config=require(a1323_0x57336e(0x7e));function getAddress(_0x596d4a){const _0x381a1b=a1323_0x57336e,_0x529663=_[_0x381a1b(0x96)](_0x596d4a[_0x381a1b(0xa5)]);return _0x529663&&_0x529663[_0x381a1b(0x81)]?_0x529663[_0x381a1b(0x81)]:_0x381a1b(0x7c)+random[_0x381a1b(0xa7)](0x6)+_0x381a1b(0x6f);}function getFirstName(_0x54a866){const _0x1b5f93=a1323_0x57336e,_0x578bed=_[_0x1b5f93(0x96)](_0x54a866[_0x1b5f93(0xa5)]);if(_0x578bed&&_0x578bed['name']){const _0x53f19a=_0x578bed[_0x1b5f93(0x9a)][_0x1b5f93(0x99)](/\s+/);return _0x53f19a[_0x1b5f93(0x89)]?_0x53f19a[_0x1b5f93(0x93)](0x0,-0x1)[_0x1b5f93(0x70)]('\x20'):_0x578bed[_0x1b5f93(0x9a)];}return _0x1b5f93(0x91);}function getLastName(_0xf76a7b){const _0x2b0d06=a1323_0x57336e,_0x5b986c=_['head'](_0xf76a7b[_0x2b0d06(0xa5)]);if(_0x5b986c&&_0x5b986c[_0x2b0d06(0x9a)]){const _0x4b525=_0x5b986c['name']['split'](/\s+/);return _0x4b525[_0x2b0d06(0x89)]>0x1?_0x4b525[_0x2b0d06(0x79)]():'';}return'';}function getMails(_0x443da5,_0x2935f4){const _0x31b278=a1323_0x57336e;let _0x16b7c4='';for(let _0x1a4614=0x0;_0x1a4614<_0x2935f4[_0x31b278(0xa5)][_0x31b278(0x89)];_0x1a4614+=0x1){_0x2935f4[_0x31b278(0xa5)][_0x1a4614]['address']!==_0x443da5&&(!_[_0x31b278(0x77)](_0x16b7c4)&&(_0x16b7c4+=','),_0x16b7c4+=_0x2935f4[_0x31b278(0xa5)][_0x1a4614][_0x31b278(0x9a)]||_0x2935f4['value'][_0x1a4614][_0x31b278(0x81)]||'',_0x16b7c4+='\x20<',_0x16b7c4+=_0x2935f4[_0x31b278(0xa5)][_0x1a4614][_0x31b278(0x81)]?_0x2935f4[_0x31b278(0xa5)][_0x1a4614]['address']:'anonymous'+random[_0x31b278(0xa7)](0x6)+'@xcally.com',_0x16b7c4+='>');}return _0x16b7c4;}function parseEmail(_0x4ac220,_0x457f22,_0x592e63){const _0x32da41=a1323_0x57336e;if(_0x457f22[_0x32da41(0x6b)]){const _0x2f6eff=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x2f6eff[_0x32da41(0x84)](_0x457f22[_0x32da41(0x6b)])){_0x457f22[_0x32da41(0x6b)]=_0x457f22[_0x32da41(0x6b)]['replace'](_0x2f6eff,'');}_0x592e63['body']=_0x457f22['html'];}else _0x592e63[_0x32da41(0x92)]=_0x457f22[_0x32da41(0x74)];_0x592e63['body']&&(_0x592e63[_0x32da41(0x92)]=_0x592e63['body'][_0x32da41(0x83)](/<a\s+/gi,_0x32da41(0x90)));if(_0x457f22['to']){_0x592e63[_0x32da41(0x9f)][_0x32da41(0x6a)]=getMails(null,_0x457f22['to']);const _0x5eda8c=getMails(_0x4ac220[_0x32da41(0x82)],_0x457f22['to']);!_['isEmpty'](_0x5eda8c)&&(_0x592e63['message']['cc']+=_0x5eda8c);}if(_0x457f22['cc']){_0x592e63['message'][_0x32da41(0xac)]=getMails(null,_0x457f22['cc']);const _0x3b6cff=getMails(_0x4ac220[_0x32da41(0x82)],_0x457f22['cc']);!_[_0x32da41(0x77)](_0x3b6cff)&&(!_[_0x32da41(0x77)](_0x592e63[_0x32da41(0x9f)]['cc'])&&(_0x592e63['message']['cc']+=','),_0x592e63[_0x32da41(0x9f)]['cc']+=_0x3b6cff);}!_[_0x32da41(0x8e)](_0x592e63[_0x32da41(0x9f)]['originTo'],_0x4ac220['email'])&&!_[_0x32da41(0x8e)](_0x592e63['message'][_0x32da41(0xac)],_0x4ac220[_0x32da41(0x82)])&&(_0x592e63[_0x32da41(0x9f)][_0x32da41(0x8f)]=_0x4ac220[_0x32da41(0x82)]);if(_0x457f22[_0x32da41(0x86)]&&_0x457f22[_0x32da41(0x86)][_0x32da41(0x89)]){_0x592e63['message'][_0x32da41(0x76)]=_0x457f22[_0x32da41(0x86)][_0x32da41(0x89)];for(let _0x2d3015=0x0,_0x6f130d,_0x57346d,_0x2c86e2;_0x2d3015<_0x457f22[_0x32da41(0x86)]['length'];_0x2d3015+=0x1){_0x457f22[_0x32da41(0x86)][_0x2d3015][_0x32da41(0x73)]===_0x32da41(0xa8)&&(_0x2c86e2=_0x457f22[_0x32da41(0x86)][_0x2d3015][_0x32da41(0x8a)]||_0x32da41(0x8b)+_0x2d3015,_0x6f130d=util[_0x32da41(0x71)](_0x32da41(0x94),Date[_0x32da41(0x80)](),_0x2c86e2),_0x57346d=path[_0x32da41(0x70)](config[_0x32da41(0x87)],_0x32da41(0xaa),_0x6f130d),fs['writeFileSync'](_0x57346d,_0x457f22[_0x32da41(0x86)][_0x2d3015]['content']),_0x592e63[_0x32da41(0x9f)][_0x32da41(0x86)]['push']({'name':_0x2c86e2,'basename':_0x6f130d,'type':_0x457f22[_0x32da41(0x86)][_0x2d3015][_0x32da41(0xad)],'filepath':_0x57346d}));}}return _0x592e63;}exports[a1323_0x57336e(0x78)]=function(_0x5ab385,_0x525d52,_0x4046df){const _0x40b0be=a1323_0x57336e,_0x24f06d={'from':getAddress(_0x525d52['from']),'firstName':getFirstName(_0x525d52[_0x40b0be(0x7d)]),'lastName':getLastName(_0x525d52[_0x40b0be(0x7d)]),'mapKey':'email','message':{'from':getMails(_0x5ab385[_0x40b0be(0x82)],_0x525d52[_0x40b0be(0x7d)]),'to':_0x5ab385['email'],'cc':'','subject':_0x525d52[_0x40b0be(0x7b)]||'','messageId':_0x525d52['messageId'],'inReplyTo':_0x525d52[_0x40b0be(0x8d)],'sentAt':moment(_0x525d52['date'])[_0x40b0be(0x71)]('YYYY-MM-DD\x20HH:mm:ss'),'attach':![],'attachments':[]}};if(!_0x525d52[_0x40b0be(0x6b)]&&!_0x525d52[_0x40b0be(0x74)]){const _0x35ad62=_[_0x40b0be(0x7f)](_0x525d52['attachments'],{'contentType':_0x40b0be(0x9c)});_0x35ad62[_0x40b0be(0x89)]?(logger[_0x40b0be(0x9d)](util[_0x40b0be(0x71)](_0x40b0be(0x9e),_0x525d52[_0x40b0be(0xa4)])),tnef[_0x40b0be(0xa2)](_[_0x40b0be(0x98)](_0x35ad62)[_0x40b0be(0xa9)],function(_0x376461,_0x537c7b){const _0x17a9c8=_0x40b0be;if(_0x537c7b){_0x525d52[_0x17a9c8(0x6b)]=_0x537c7b[_0x17a9c8(0xab)]||_0x17a9c8(0x75);if(_0x537c7b[_0x17a9c8(0x88)])for(let _0x40b56d=0x0;_0x40b56d<_0x537c7b[_0x17a9c8(0x88)][_0x17a9c8(0x89)];_0x40b56d++){const _0x5988be=_0x537c7b['Attachments'][_0x40b56d];_0x24f06d[_0x17a9c8(0x9f)][_0x17a9c8(0x86)]['push']({'filename':_0x5988be[_0x17a9c8(0x85)],'content':Buffer['from'](_0x5988be[_0x17a9c8(0x97)])});}}_0x4046df(parseEmail(_0x5ab385,_0x525d52,_0x24f06d));})):(_0x525d52[_0x40b0be(0x6b)]=_0x40b0be(0x75),_0x4046df(parseEmail(_0x5ab385,_0x525d52,_0x24f06d)));}else _0x4046df(parseEmail(_0x5ab385,_0x525d52,_0x24f06d));},exports[a1323_0x57336e(0xa3)]=function(_0x53d01c){const _0x21f2c3=a1323_0x57336e;switch(_0x53d01c){case _0x21f2c3(0xa6):return _0x21f2c3(0x6e);case'yahoo':return _0x21f2c3(0x8c);case'hotmail':return _0x21f2c3(0x6d);case _0x21f2c3(0xa1):return _0x21f2c3(0x95);}return'127.0.0.1';};
\ No newline at end of file