Prepare one click unsubscribe

This commit is contained in:
M66B
2024-02-01 13:41:42 +01:00
parent 6c4ad3401c
commit e5853451e0
2 changed files with 19 additions and 7 deletions

View File

@@ -2761,13 +2761,12 @@ public class MessageHelper {
}
}
String getListUnsubscribe() throws MessagingException {
Pair<String, Boolean> getListUnsubscribe() throws MessagingException {
ensureHeaders();
String list;
try {
// https://www.ietf.org/rfc/rfc2369.txt
list = imessage.getHeader("List-Unsubscribe", null);
String list = imessage.getHeader("List-Unsubscribe", null);
if (list == null)
return null;
@@ -2777,6 +2776,15 @@ public class MessageHelper {
if (list == null || list.startsWith("NO"))
return null;
// https://datatracker.ietf.org/doc/html/rfc8058
boolean onclick = false;
String post = imessage.getHeader("List-Unsubscribe-Post", null);
if (post != null) {
post = MimeUtility.unfold(post);
post = decodeMime(post);
onclick = "List-Unsubscribe=One-Click".equalsIgnoreCase(post.trim());
}
String link = null;
String mailto = null;
int s = list.indexOf('<');
@@ -2821,9 +2829,9 @@ public class MessageHelper {
}
if (link != null)
return link;
return new Pair<>(link, onclick);
if (mailto != null)
return mailto;
return new Pair<>(mailto, onclick);
if (!BuildConfig.PLAY_STORE_RELEASE)
Log.i(new IllegalArgumentException("List-Unsubscribe: " + list));