Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / email / lib / utils.js
index 5ff9eab..8abd32d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xaf8b=['anonymous','generate','@xcally.com','head','value','name','split','length','slice','join','Anonymous','address','isEmpty','html','test','replace','body','textAsHtml','<a\x20target=\x22_blank\x22\x20','message','originTo','originCc','bcc','attachments','attach','attachment','filename','attachment-','format','%s-%s','now','server/files/attachments/','writeFileSync','content','push','contentType','parser','from','subject','messageId','inReplyTo','YYYY-MM-DD\x20HH:mm:ss','filter','info','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','first','BodyHTML','Attachments','Title','Data','<p>Empty\x20message</p>','gmail','imap.gmail.com','yahoo','outlook365','outlook.office365.com','127.0.0.1','moment','randomstring','path','util','node-tnef','../../../config/logger','email','../../../config/environment'];(function(_0x443697,_0x438d17){var _0x36f6d2=function(_0x6eaa91){while(--_0x6eaa91){_0x443697['push'](_0x443697['shift']());}};_0x36f6d2(++_0x438d17);}(_0xaf8b,0x13d));var _0xbaf8=function(_0x436c67,_0x1a7db2){_0x436c67=_0x436c67-0x0;var _0x2745dd=_0xaf8b[_0x436c67];return _0x2745dd;};'use strict';var _=require('lodash');var moment=require(_0xbaf8('0x0'));var random=require(_0xbaf8('0x1'));var fs=require('fs');var path=require(_0xbaf8('0x2'));var util=require(_0xbaf8('0x3'));var tnef=require(_0xbaf8('0x4'));var logger=require(_0xbaf8('0x5'))(_0xbaf8('0x6'));var config=require(_0xbaf8('0x7'));function getAddress(_0x5a2cf6){var _0x28bc0e=_['head'](_0x5a2cf6['value']);return _0x28bc0e&&_0x28bc0e['address']?_0x28bc0e['address']:_0xbaf8('0x8')+random[_0xbaf8('0x9')](0x6)+_0xbaf8('0xa');}function getFirstName(_0x279a48){var _0x3ea8d9=_[_0xbaf8('0xb')](_0x279a48[_0xbaf8('0xc')]);if(_0x3ea8d9&&_0x3ea8d9[_0xbaf8('0xd')]){var _0xe2be8e=_0x3ea8d9['name'][_0xbaf8('0xe')](/\s+/);return _0xe2be8e[_0xbaf8('0xf')]?_0xe2be8e[_0xbaf8('0x10')](0x0,-0x1)[_0xbaf8('0x11')]('\x20'):_0x3ea8d9[_0xbaf8('0xd')];}return _0xbaf8('0x12');}function getLastName(_0x281fdb){var _0x4b94ba=_[_0xbaf8('0xb')](_0x281fdb[_0xbaf8('0xc')]);if(_0x4b94ba&&_0x4b94ba[_0xbaf8('0xd')]){var _0x17ab9a=_0x4b94ba['name'][_0xbaf8('0xe')](/\s+/);return _0x17ab9a[_0xbaf8('0xf')]>0x1?_0x17ab9a['pop']():'';}return'';}function getMails(_0x728285,_0x3892f3){var _0x41d63e='';for(var _0x334115=0x0;_0x334115<_0x3892f3[_0xbaf8('0xc')]['length'];_0x334115+=0x1){if(_0x3892f3[_0xbaf8('0xc')][_0x334115][_0xbaf8('0x13')]!==_0x728285){if(!_[_0xbaf8('0x14')](_0x41d63e)){_0x41d63e+=',';}_0x41d63e+=_0x3892f3[_0xbaf8('0xc')][_0x334115][_0xbaf8('0xd')]||_0x3892f3[_0xbaf8('0xc')][_0x334115][_0xbaf8('0x13')]||'';_0x41d63e+='\x20<';_0x41d63e+=_0x3892f3[_0xbaf8('0xc')][_0x334115][_0xbaf8('0x13')]?_0x3892f3[_0xbaf8('0xc')][_0x334115][_0xbaf8('0x13')]:_0xbaf8('0x8')+random[_0xbaf8('0x9')](0x6)+_0xbaf8('0xa');_0x41d63e+='>';}}return _0x41d63e;}function parseEmail(_0x22b5d2,_0x2433a0,_0x449f92){if(_0x2433a0[_0xbaf8('0x15')]){var _0x3aa9fb=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x3aa9fb[_0xbaf8('0x16')](_0x2433a0[_0xbaf8('0x15')])){_0x2433a0['html']=_0x2433a0[_0xbaf8('0x15')][_0xbaf8('0x17')](_0x3aa9fb,'');}_0x449f92[_0xbaf8('0x18')]=_0x2433a0[_0xbaf8('0x15')];}else{_0x449f92[_0xbaf8('0x18')]=_0x2433a0[_0xbaf8('0x19')];}if(_0x449f92['body']){_0x449f92[_0xbaf8('0x18')]=_0x449f92[_0xbaf8('0x18')][_0xbaf8('0x17')](/<a\s+/gi,_0xbaf8('0x1a'));}if(_0x2433a0['to']){_0x449f92[_0xbaf8('0x1b')][_0xbaf8('0x1c')]=getMails(null,_0x2433a0['to']);var _0x14626a=getMails(_0x22b5d2[_0xbaf8('0x6')],_0x2433a0['to']);if(!_['isEmpty'](_0x14626a)){_0x449f92[_0xbaf8('0x1b')]['cc']+=_0x14626a;}}if(_0x2433a0['cc']){_0x449f92['message'][_0xbaf8('0x1d')]=getMails(null,_0x2433a0['cc']);var _0x59d774=getMails(_0x22b5d2[_0xbaf8('0x6')],_0x2433a0['cc']);if(!_['isEmpty'](_0x59d774)){if(!_[_0xbaf8('0x14')](_0x449f92[_0xbaf8('0x1b')]['cc'])){_0x449f92[_0xbaf8('0x1b')]['cc']+=',';}_0x449f92[_0xbaf8('0x1b')]['cc']+=_0x59d774;}}if(!_['includes'](_0x449f92[_0xbaf8('0x1b')][_0xbaf8('0x1c')],_0x22b5d2[_0xbaf8('0x6')])&&!_['includes'](_0x449f92[_0xbaf8('0x1b')][_0xbaf8('0x1d')],_0x22b5d2['email'])){_0x449f92[_0xbaf8('0x1b')][_0xbaf8('0x1e')]=_0x22b5d2['email'];}if(_0x2433a0[_0xbaf8('0x1f')]&&_0x2433a0[_0xbaf8('0x1f')]['length']){_0x449f92[_0xbaf8('0x1b')][_0xbaf8('0x20')]=_0x2433a0[_0xbaf8('0x1f')][_0xbaf8('0xf')];for(var _0x20364c=0x0,_0x10e3be,_0xfe0270,_0x155147;_0x20364c<_0x2433a0['attachments'][_0xbaf8('0xf')];_0x20364c+=0x1){if(_0x2433a0['attachments'][_0x20364c]['type']===_0xbaf8('0x21')){_0x155147=_0x2433a0['attachments'][_0x20364c][_0xbaf8('0x22')]||_0xbaf8('0x23')+_0x20364c;_0x10e3be=util[_0xbaf8('0x24')](_0xbaf8('0x25'),Date[_0xbaf8('0x26')](),_0x155147);_0xfe0270=path[_0xbaf8('0x11')](config['root'],_0xbaf8('0x27'),_0x10e3be);fs[_0xbaf8('0x28')](_0xfe0270,_0x2433a0['attachments'][_0x20364c][_0xbaf8('0x29')]);_0x449f92[_0xbaf8('0x1b')][_0xbaf8('0x1f')][_0xbaf8('0x2a')]({'name':_0x155147,'basename':_0x10e3be,'type':_0x2433a0['attachments'][_0x20364c][_0xbaf8('0x2b')],'filepath':_0xfe0270});}}}return _0x449f92;}exports[_0xbaf8('0x2c')]=function(_0x43bf4e,_0x5a5b30,_0x4e6798){var _0x16a48b={'from':getAddress(_0x5a5b30[_0xbaf8('0x2d')]),'firstName':getFirstName(_0x5a5b30[_0xbaf8('0x2d')]),'lastName':getLastName(_0x5a5b30[_0xbaf8('0x2d')]),'mapKey':'email','message':{'from':getMails(_0x43bf4e[_0xbaf8('0x6')],_0x5a5b30[_0xbaf8('0x2d')]),'to':_0x43bf4e[_0xbaf8('0x6')],'cc':'','subject':_0x5a5b30[_0xbaf8('0x2e')]||'','messageId':_0x5a5b30[_0xbaf8('0x2f')],'inReplyTo':_0x5a5b30[_0xbaf8('0x30')],'sentAt':moment(_0x5a5b30['date'])[_0xbaf8('0x24')](_0xbaf8('0x31')),'attach':![],'attachments':[]}};if(!_0x5a5b30[_0xbaf8('0x15')]&&!_0x5a5b30[_0xbaf8('0x19')]){var _0x414cde=_[_0xbaf8('0x32')](_0x5a5b30[_0xbaf8('0x1f')],{'contentType':'application/ms-tnef'});if(_0x414cde['length']){logger[_0xbaf8('0x33')](util[_0xbaf8('0x24')](_0xbaf8('0x34'),_0x5a5b30['messageId']));tnef['parseBuffer'](_[_0xbaf8('0x35')](_0x414cde)['content'],function(_0xbd5aad,_0x414d3c){if(_0x414d3c){_0x5a5b30[_0xbaf8('0x15')]=_0x414d3c[_0xbaf8('0x36')]||'<p>Empty\x20message</p>';if(_0x414d3c[_0xbaf8('0x37')]){for(var _0x3450b1=0x0;_0x3450b1<_0x414d3c[_0xbaf8('0x37')][_0xbaf8('0xf')];_0x3450b1++){var _0x3e6197=_0x414d3c['Attachments'][_0x3450b1];_0x16a48b['message'][_0xbaf8('0x1f')][_0xbaf8('0x2a')]({'filename':_0x3e6197[_0xbaf8('0x38')],'content':new Buffer(_0x3e6197[_0xbaf8('0x39')])});}}}_0x4e6798(parseEmail(_0x43bf4e,_0x5a5b30,_0x16a48b));});}else{_0x5a5b30[_0xbaf8('0x15')]=_0xbaf8('0x3a');_0x4e6798(parseEmail(_0x43bf4e,_0x5a5b30,_0x16a48b));}}else{_0x4e6798(parseEmail(_0x43bf4e,_0x5a5b30,_0x16a48b));}};exports['getHost']=function(_0x6e7330){switch(_0x6e7330){case _0xbaf8('0x3b'):return _0xbaf8('0x3c');case _0xbaf8('0x3d'):return'imap.mail.yahoo.com';case'hotmail':return'imap-mail.outlook.com';case _0xbaf8('0x3e'):return _0xbaf8('0x3f');}return _0xbaf8('0x40');};
\ No newline at end of file
+var _0x6fdf=['replace','<a\x20target=\x22_blank\x22\x20','originTo','message','originCc','includes','attachments','attach','type','attachment-','format','%s-%s','now','root','server/files/attachments/','writeFileSync','push','parser','from','subject','messageId','date','YYYY-MM-DD\x20HH:mm:ss','filter','application/ms-tnef','info','Email\x20message\x20%s\x20is\x20in\x20TNEF\x20format:\x20message\x20content\x20will\x20be\x20converted\x20by\x20the\x20system','parseBuffer','BodyHTML','Attachments','Data','<p>Empty\x20message</p>','gmail','imap.gmail.com','yahoo','imap.mail.yahoo.com','hotmail','imap-mail.outlook.com','127.0.0.1','lodash','moment','path','../../../config/logger','email','../../../config/environment','head','value','address','generate','split','length','slice','join','name','Anonymous','pop','isEmpty','anonymous','@xcally.com','test','html','body','textAsHtml'];(function(_0x457f1c,_0x33c255){var _0x18ced4=function(_0x1e0717){while(--_0x1e0717){_0x457f1c['push'](_0x457f1c['shift']());}};_0x18ced4(++_0x33c255);}(_0x6fdf,0xe4));var _0xf6fd=function(_0x4465e2,_0x276e3f){_0x4465e2=_0x4465e2-0x0;var _0x1fc7dd=_0x6fdf[_0x4465e2];return _0x1fc7dd;};'use strict';var _=require(_0xf6fd('0x0'));var moment=require(_0xf6fd('0x1'));var random=require('randomstring');var fs=require('fs');var path=require(_0xf6fd('0x2'));var util=require('util');var tnef=require('node-tnef');var logger=require(_0xf6fd('0x3'))(_0xf6fd('0x4'));var config=require(_0xf6fd('0x5'));function getAddress(_0x208bba){var _0x4eecc3=_[_0xf6fd('0x6')](_0x208bba[_0xf6fd('0x7')]);return _0x4eecc3&&_0x4eecc3[_0xf6fd('0x8')]?_0x4eecc3[_0xf6fd('0x8')]:'anonymous'+random[_0xf6fd('0x9')](0x6)+'@xcally.com';}function getFirstName(_0x1d500c){var _0x3492d8=_[_0xf6fd('0x6')](_0x1d500c[_0xf6fd('0x7')]);if(_0x3492d8&&_0x3492d8['name']){var _0x305673=_0x3492d8['name'][_0xf6fd('0xa')](/\s+/);return _0x305673[_0xf6fd('0xb')]?_0x305673[_0xf6fd('0xc')](0x0,-0x1)[_0xf6fd('0xd')]('\x20'):_0x3492d8[_0xf6fd('0xe')];}return _0xf6fd('0xf');}function getLastName(_0x49f6a6){var _0x400a9d=_[_0xf6fd('0x6')](_0x49f6a6[_0xf6fd('0x7')]);if(_0x400a9d&&_0x400a9d[_0xf6fd('0xe')]){var _0x2ee25b=_0x400a9d['name'][_0xf6fd('0xa')](/\s+/);return _0x2ee25b[_0xf6fd('0xb')]>0x1?_0x2ee25b[_0xf6fd('0x10')]():'';}return'';}function getMails(_0x55d996,_0x594ab8){var _0x1a3a20='';for(var _0x5b57ce=0x0;_0x5b57ce<_0x594ab8['value'][_0xf6fd('0xb')];_0x5b57ce+=0x1){if(_0x594ab8[_0xf6fd('0x7')][_0x5b57ce][_0xf6fd('0x8')]!==_0x55d996){if(!_[_0xf6fd('0x11')](_0x1a3a20)){_0x1a3a20+=',';}_0x1a3a20+=_0x594ab8[_0xf6fd('0x7')][_0x5b57ce][_0xf6fd('0xe')]||_0x594ab8['value'][_0x5b57ce]['address']||'';_0x1a3a20+='\x20<';_0x1a3a20+=_0x594ab8[_0xf6fd('0x7')][_0x5b57ce]['address']?_0x594ab8[_0xf6fd('0x7')][_0x5b57ce][_0xf6fd('0x8')]:_0xf6fd('0x12')+random[_0xf6fd('0x9')](0x6)+_0xf6fd('0x13');_0x1a3a20+='>';}}return _0x1a3a20;}function parseEmail(_0x2fba71,_0x458e37,_0x505671){if(_0x458e37['html']){var _0x382483=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;while(_0x382483[_0xf6fd('0x14')](_0x458e37[_0xf6fd('0x15')])){_0x458e37[_0xf6fd('0x15')]=_0x458e37[_0xf6fd('0x15')]['replace'](_0x382483,'');}_0x505671[_0xf6fd('0x16')]=_0x458e37[_0xf6fd('0x15')];}else{_0x505671[_0xf6fd('0x16')]=_0x458e37[_0xf6fd('0x17')];}if(_0x505671[_0xf6fd('0x16')]){_0x505671[_0xf6fd('0x16')]=_0x505671[_0xf6fd('0x16')][_0xf6fd('0x18')](/<a\s+/gi,_0xf6fd('0x19'));}if(_0x458e37['to']){_0x505671['message'][_0xf6fd('0x1a')]=getMails(null,_0x458e37['to']);var _0x1594b5=getMails(_0x2fba71[_0xf6fd('0x4')],_0x458e37['to']);if(!_['isEmpty'](_0x1594b5)){_0x505671[_0xf6fd('0x1b')]['cc']+=_0x1594b5;}}if(_0x458e37['cc']){_0x505671[_0xf6fd('0x1b')][_0xf6fd('0x1c')]=getMails(null,_0x458e37['cc']);var _0x463efa=getMails(_0x2fba71[_0xf6fd('0x4')],_0x458e37['cc']);if(!_[_0xf6fd('0x11')](_0x463efa)){if(!_[_0xf6fd('0x11')](_0x505671[_0xf6fd('0x1b')]['cc'])){_0x505671[_0xf6fd('0x1b')]['cc']+=',';}_0x505671[_0xf6fd('0x1b')]['cc']+=_0x463efa;}}if(!_['includes'](_0x505671[_0xf6fd('0x1b')][_0xf6fd('0x1a')],_0x2fba71[_0xf6fd('0x4')])&&!_[_0xf6fd('0x1d')](_0x505671[_0xf6fd('0x1b')][_0xf6fd('0x1c')],_0x2fba71[_0xf6fd('0x4')])){_0x505671['message']['bcc']=_0x2fba71['email'];}if(_0x458e37[_0xf6fd('0x1e')]&&_0x458e37['attachments'][_0xf6fd('0xb')]){_0x505671[_0xf6fd('0x1b')][_0xf6fd('0x1f')]=_0x458e37[_0xf6fd('0x1e')][_0xf6fd('0xb')];for(var _0x46db9b=0x0,_0x55a05b,_0x4c35df,_0x38b560;_0x46db9b<_0x458e37['attachments']['length'];_0x46db9b+=0x1){if(_0x458e37[_0xf6fd('0x1e')][_0x46db9b][_0xf6fd('0x20')]==='attachment'){_0x38b560=_0x458e37[_0xf6fd('0x1e')][_0x46db9b]['filename']||_0xf6fd('0x21')+_0x46db9b;_0x55a05b=util[_0xf6fd('0x22')](_0xf6fd('0x23'),Date[_0xf6fd('0x24')](),_0x38b560);_0x4c35df=path[_0xf6fd('0xd')](config[_0xf6fd('0x25')],_0xf6fd('0x26'),_0x55a05b);fs[_0xf6fd('0x27')](_0x4c35df,_0x458e37[_0xf6fd('0x1e')][_0x46db9b]['content']);_0x505671[_0xf6fd('0x1b')][_0xf6fd('0x1e')][_0xf6fd('0x28')]({'name':_0x38b560,'basename':_0x55a05b,'type':_0x458e37[_0xf6fd('0x1e')][_0x46db9b]['contentType'],'filepath':_0x4c35df});}}}return _0x505671;}exports[_0xf6fd('0x29')]=function(_0xd109d8,_0x3ab7a4,_0x50ba55){var _0x24a5c1={'from':getAddress(_0x3ab7a4[_0xf6fd('0x2a')]),'firstName':getFirstName(_0x3ab7a4[_0xf6fd('0x2a')]),'lastName':getLastName(_0x3ab7a4[_0xf6fd('0x2a')]),'mapKey':_0xf6fd('0x4'),'message':{'from':getMails(_0xd109d8[_0xf6fd('0x4')],_0x3ab7a4[_0xf6fd('0x2a')]),'to':_0xd109d8['email'],'cc':'','subject':_0x3ab7a4[_0xf6fd('0x2b')]||'','messageId':_0x3ab7a4[_0xf6fd('0x2c')],'inReplyTo':_0x3ab7a4['inReplyTo'],'sentAt':moment(_0x3ab7a4[_0xf6fd('0x2d')])[_0xf6fd('0x22')](_0xf6fd('0x2e')),'attach':![],'attachments':[]}};if(!_0x3ab7a4['html']&&!_0x3ab7a4[_0xf6fd('0x17')]){var _0x37a8a8=_[_0xf6fd('0x2f')](_0x3ab7a4[_0xf6fd('0x1e')],{'contentType':_0xf6fd('0x30')});if(_0x37a8a8[_0xf6fd('0xb')]){logger[_0xf6fd('0x31')](util[_0xf6fd('0x22')](_0xf6fd('0x32'),_0x3ab7a4[_0xf6fd('0x2c')]));tnef[_0xf6fd('0x33')](_['first'](_0x37a8a8)['content'],function(_0x5b50a5,_0x19737b){if(_0x19737b){_0x3ab7a4[_0xf6fd('0x15')]=_0x19737b[_0xf6fd('0x34')]||'<p>Empty\x20message</p>';if(_0x19737b[_0xf6fd('0x35')]){for(var _0x45384d=0x0;_0x45384d<_0x19737b[_0xf6fd('0x35')][_0xf6fd('0xb')];_0x45384d++){var _0x1d66d4=_0x19737b[_0xf6fd('0x35')][_0x45384d];_0x24a5c1[_0xf6fd('0x1b')][_0xf6fd('0x1e')][_0xf6fd('0x28')]({'filename':_0x1d66d4['Title'],'content':new Buffer(_0x1d66d4[_0xf6fd('0x36')])});}}}_0x50ba55(parseEmail(_0xd109d8,_0x3ab7a4,_0x24a5c1));});}else{_0x3ab7a4['html']=_0xf6fd('0x37');_0x50ba55(parseEmail(_0xd109d8,_0x3ab7a4,_0x24a5c1));}}else{_0x50ba55(parseEmail(_0xd109d8,_0x3ab7a4,_0x24a5c1));}};exports['getHost']=function(_0x8239f8){switch(_0x8239f8){case _0xf6fd('0x38'):return _0xf6fd('0x39');case _0xf6fd('0x3a'):return _0xf6fd('0x3b');case _0xf6fd('0x3c'):return _0xf6fd('0x3d');case'outlook365':return'outlook.office365.com';}return _0xf6fd('0x3e');};
\ No newline at end of file