1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-21 08:30:23 -07:00

Merge pull request #37 from Ionic/feature/rework-unsubscribe

Rework Unsubscribe header parsing
This commit is contained in:
Andrew Van Tassel 2024-07-24 16:25:00 -06:00 committed by GitHub
commit 8b80fafaba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -379,11 +379,15 @@ class MailHops {
} }
} }
if (header_unsubscribe) { if (header_unsubscribe) {
auth.push({ var unsubscribeArr = header_unsubscribe.split(',');
type: 'Unsubscribe',
color: 'grey', for (var i = 0; i < unsubscribeArr.length; ++i) {
link: header_unsubscribe.replace('<', '').replace('>', '').trim() auth.push({
}); type: 'Unsubscribe',
color: 'grey',
link: unsubscribeArr[i].replace(/</, '').replace(/>/, '').trim()
});
}
} }
return auth; return auth;
} }

View File

@ -147,6 +147,11 @@ function updateContent(msg, noauth) {
} }
else if (msg.message.auth[a].link) { else if (msg.message.auth[a].link) {
var add = ''; var add = '';
// We only check for a comma in case our base code failed to split
// the header links up correctly.
// Usually, it should work fine and add multiple buttons for
// multiple links.
if (-1 != msg.message.auth[a].link.indexOf(',')) { if (-1 != msg.message.auth[a].link.indexOf(',')) {
add = '<a class="tiny ui label ' + msg.message.auth[a].color + '" href="'+msg.message.auth[a].link.substr(0,msg.message.auth[a].link.indexOf(','))+'" target="_blank">' + msg.message.auth[a].type + '</a>'; add = '<a class="tiny ui label ' + msg.message.auth[a].color + '" href="'+msg.message.auth[a].link.substr(0,msg.message.auth[a].link.indexOf(','))+'" target="_blank">' + msg.message.auth[a].type + '</a>';
} }