Require DMARC for BIMI images

master
M66B 1 month ago
parent 0934759a77
commit 7171455db7

@ -1293,6 +1293,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
message.folderUnified && outgoing) ||
EntityFolder.isOutgoing(message.folderInheritedType));
String selector = (reverse ? null : message.bimi_selector);
boolean dmarc = (!reverse && Boolean.TRUE.equals(message.dmarc));
Address[] addresses = (reverse ? message.to : (message.isForwarder() ? message.submitter : message.from));
Address[] senders = ContactInfo.fillIn(
reverse && !show_recipients ? message.to : message.senders, prefer_contact, only_contact);
@ -1666,7 +1667,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Contact info
ContactInfo[] info = ContactInfo.getCached(context,
message.account, message.folderType, selector, addresses);
message.account, message.folderType, selector, dmarc, addresses);
if (info == null) {
if (taskContactInfo != null) {
taskContactInfo.cancel(context);
@ -1678,6 +1679,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
aargs.putLong("account", message.account);
aargs.putString("folderType", message.folderType);
aargs.putString("selector", selector);
aargs.putBoolean("dmarc", dmarc);
aargs.putSerializable("addresses", addresses);
taskContactInfo = new SimpleTask<ContactInfo[]>() {
@ -1686,8 +1688,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
long account = args.getLong("account");
String folderType = args.getString("folderType");
String selector = args.getString("selector");
boolean dmarc = args.getBoolean("dmarc");
Address[] addresses = (Address[]) args.getSerializable("addresses");
return ContactInfo.get(context, account, folderType, selector, addresses);
return ContactInfo.get(context, account, folderType, selector, dmarc, addresses);
}
@Override
@ -7502,6 +7505,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
args.putLong("account", message.account);
args.putString("folderType", message.folderType);
args.putString("selector", message.bimi_selector);
args.putBoolean("dmarc", Boolean.TRUE.equals(message.dmarc));
args.putSerializable("addresses", message.from);
new SimpleTask<ContactInfo[]>() {
@ -7510,8 +7514,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
long account = args.getLong("account");
String folderType = args.getString("folderType");
String selector = args.getString("selector");
boolean dmarc = args.getBoolean("dmarc");
Address[] addresses = (Address[]) args.getSerializable("addresses");
return ContactInfo.get(context, account, folderType, selector, addresses);
return ContactInfo.get(context, account, folderType, selector, dmarc, addresses);
}
@Override

@ -219,15 +219,15 @@ public class ContactInfo {
}
@NonNull
static ContactInfo[] get(Context context, long account, String folderType, String selector, Address[] addresses) {
return get(context, account, folderType, selector, addresses, false);
static ContactInfo[] get(Context context, long account, String folderType, String selector, boolean dmarc, Address[] addresses) {
return get(context, account, folderType, selector, dmarc, addresses, false);
}
static ContactInfo[] getCached(Context context, long account, String folderType, String selector, Address[] addresses) {
return get(context, account, folderType, selector, addresses, true);
static ContactInfo[] getCached(Context context, long account, String folderType, String selector, boolean dmarc, Address[] addresses) {
return get(context, account, folderType, selector, dmarc, addresses, true);
}
private static ContactInfo[] get(Context context, long account, String folderType, String selector, Address[] addresses, boolean cacheOnly) {
private static ContactInfo[] get(Context context, long account, String folderType, String selector, boolean dmarc, Address[] addresses, boolean cacheOnly) {
if (addresses == null || addresses.length == 0) {
ContactInfo anonymous = getAnonymous(context);
return new ContactInfo[]{anonymous == null ? new ContactInfo() : anonymous};
@ -235,7 +235,7 @@ public class ContactInfo {
ContactInfo[] result = new ContactInfo[addresses.length];
for (int i = 0; i < addresses.length; i++) {
result[i] = _get(context, account, folderType, selector, (InternetAddress) addresses[i], cacheOnly);
result[i] = _get(context, account, folderType, selector, dmarc, (InternetAddress) addresses[i], cacheOnly);
if (result[i] == null) {
if (cacheOnly)
return null;
@ -257,7 +257,7 @@ public class ContactInfo {
private static ContactInfo _get(
Context context,
long account, String folderType,
String selector, InternetAddress address, boolean cacheOnly) {
String selector, boolean dmarc, InternetAddress address, boolean cacheOnly) {
String key = MessageHelper.formatAddresses(new Address[]{address});
synchronized (emailContactInfo) {
ContactInfo info = emailContactInfo.get(key);
@ -277,7 +277,7 @@ public class ContactInfo {
boolean avatars = prefs.getBoolean("avatars", true);
boolean prefer_contact = prefs.getBoolean("prefer_contact", false);
boolean distinguish_contacts = prefs.getBoolean("distinguish_contacts", false);
boolean bimi = (prefs.getBoolean("bimi", false) && !BuildConfig.PLAY_STORE_RELEASE);
boolean bimi = (prefs.getBoolean("bimi", false) && dmarc && !BuildConfig.PLAY_STORE_RELEASE);
boolean gravatars = (prefs.getBoolean("gravatars", false) && !BuildConfig.PLAY_STORE_RELEASE);
boolean libravatars = (prefs.getBoolean("libravatars", false) && !BuildConfig.PLAY_STORE_RELEASE);
boolean favicons = prefs.getBoolean("favicons", false);

@ -712,7 +712,8 @@ class NotificationHelper {
for (int m = 0; m < messages.size() && m < MAX_NOTIFICATION_DISPLAY; m++) {
TupleMessageEx message = messages.get(m);
ContactInfo[] info = ContactInfo.get(context,
message.account, message.folderType, message.bimi_selector,
message.account, message.folderType,
message.bimi_selector, Boolean.TRUE.equals(message.dmarc),
message.isForwarder() ? message.submitter : message.from);
Address[] modified = (message.from == null

@ -238,7 +238,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
if (avatars) {
ContactInfo[] info = ContactInfo.get(context,
message.account, null, message.bimi_selector,
message.account, null,
message.bimi_selector, Boolean.TRUE.equals(message.dmarc),
message.isForwarder() ? message.submitter : message.from);
views.setImageViewBitmap(R.id.avatar, info.length == 0 ? null : info[0].getPhotoBitmap());
}

Loading…
Cancel
Save