mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 08:33:37 +02:00
Prepare one click unsubscribe
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user