Added option to disable authentication check

This commit is contained in:
M66B 2021-06-10 16:19:58 +02:00
parent 438a2f1583
commit 9f8e8585a0
6 changed files with 61 additions and 22 deletions

View File

@ -245,6 +245,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean indentation;
private boolean avatars;
private boolean color_stripe;
private boolean check_authentication;
private boolean check_reply_domain;
private MessageHelper.AddressFormat email_format;
private boolean prefer_contact;
private boolean only_contact;
@ -948,11 +951,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Address[] recipients = ContactInfo.fillIn(
reverse && !show_recipients ? message.from : message.recipients, prefer_contact, only_contact);
boolean authenticated =
!(Boolean.FALSE.equals(message.dkim) ||
Boolean.FALSE.equals(message.spf) ||
Boolean.FALSE.equals(message.dmarc) ||
!((Boolean.FALSE.equals(message.dkim) && check_authentication) ||
(Boolean.FALSE.equals(message.spf) && check_authentication) ||
(Boolean.FALSE.equals(message.dmarc) && check_authentication) ||
Boolean.FALSE.equals(message.mx) ||
Boolean.FALSE.equals(message.reply_domain));
(Boolean.FALSE.equals(message.reply_domain) && check_reply_domain));
boolean expanded = (viewType == ViewType.THREAD && properties.getValue("expanded", message.id));
// Text size
@ -5586,6 +5589,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.avatars = (contacts && avatars) || (gravatars || favicons || generated);
this.color_stripe = prefs.getBoolean("color_stripe", true);
this.check_authentication = prefs.getBoolean("check_authentication", true);
this.check_reply_domain = prefs.getBoolean("check_reply_domain", true);
this.email_format = MessageHelper.getAddressFormat(context);
this.prefer_contact = prefs.getBoolean("prefer_contact", false);
this.only_contact = prefs.getBoolean("only_contact", false);

View File

@ -3315,20 +3315,17 @@ class Core {
if (message.avatar == null && notify_known && pro)
message.ui_ignored = true;
boolean check_reply_domain = prefs.getBoolean("check_reply_domain", true);
if (check_reply_domain) {
// For contact forms
boolean self = false;
if (identity != null && message.from != null)
for (Address from : message.from)
if (identity.sameAddress(from) || identity.similarAddress(from)) {
self = true;
break;
}
if (!self) {
String warning = message.checkReplyDomain(context);
message.reply_domain = (warning == null);
}
// For contact forms
boolean self = false;
if (identity != null && message.from != null)
for (Address from : message.from)
if (identity.sameAddress(from) || identity.similarAddress(from)) {
self = true;
break;
}
if (!self) {
String warning = message.checkReplyDomain(context);
message.reply_domain = (warning == null);
}
boolean check_mx = prefs.getBoolean("check_mx", false);

View File

@ -81,7 +81,7 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync",
"subscriptions",
"subscriptions", "check_authentication", "check_reply_domain",
"send_pending",
"portrait2", "landscape", "landscape3", "startup", "cards", "beige", "shadow_unread",
"indentation", "date", "date_bold", "threading", "threading_unread",

View File

@ -81,6 +81,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private SwitchCompat swSyncFolders;
private SwitchCompat swSyncSharedFolders;
private SwitchCompat swSubscriptions;
private SwitchCompat swCheckAuthentication;
private SwitchCompat swCheckReply;
private SwitchCompat swCheckMx;
private SwitchCompat swTuneKeepAlive;
@ -92,7 +93,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
"enabled", "poll_interval", "auto_optimize", "schedule", "schedule_start", "schedule_end",
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id",
"sync_folders", "sync_shared_folders", "subscriptions",
"check_reply_domain", "check_mx", "tune_keep_alive"
"check_authentication", "check_reply_domain", "check_mx", "tune_keep_alive"
};
@Override
@ -135,6 +136,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swSyncFolders = view.findViewById(R.id.swSyncFolders);
swSyncSharedFolders = view.findViewById(R.id.swSyncSharedFolders);
swSubscriptions = view.findViewById(R.id.swSubscriptions);
swCheckAuthentication = view.findViewById(R.id.swCheckAuthentication);
swCheckReply = view.findViewById(R.id.swCheckReply);
swCheckMx = view.findViewById(R.id.swCheckMx);
swTuneKeepAlive = view.findViewById(R.id.swTuneKeepAlive);
@ -311,6 +313,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
});
swCheckAuthentication.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putBoolean("check_authentication", checked).apply();
}
});
swCheckReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -417,6 +426,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swSyncSharedFolders.setChecked(prefs.getBoolean("sync_shared_folders", false));
swSyncSharedFolders.setEnabled(swSyncFolders.isChecked());
swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false));
swCheckAuthentication.setChecked(prefs.getBoolean("check_authentication", true));
swCheckReply.setChecked(prefs.getBoolean("check_reply_domain", true));
swCheckMx.setChecked(prefs.getBoolean("check_mx", false));
swTuneKeepAlive.setChecked(prefs.getBoolean("tune_keep_alive", true));

View File

@ -558,6 +558,30 @@
app:layout_constraintTop_toBottomOf="@id/swSyncSharedFolders"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCheckAuthentication"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_check_authentication"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubscriptions"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvCheckAuthenticationHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_check_authentication_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCheckAuthentication" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCheckReply"
android:layout_width="0dp"
@ -567,7 +591,7 @@
android:text="@string/title_advanced_check_reply_domain"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubscriptions"
app:layout_constraintTop_toBottomOf="@id/tvCheckAuthenticationHint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
@ -632,4 +656,4 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>
</eu.faircode.email.ScrollViewEx>

View File

@ -303,6 +303,7 @@
<string name="title_advanced_sync_folders">Synchronize folder list</string>
<string name="title_advanced_sync_shared_folders">Synchronize shared folder lists</string>
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_check_authentication">Check message authentication</string>
<string name="title_advanced_check_reply_domain">Check reply address on synchronizing messages</string>
<string name="title_advanced_check_mx">Check sender email addresses on synchronizing messages</string>
<string name="title_advanced_tune_keep_alive">Automatically tune the keep-alive interval</string>
@ -586,6 +587,7 @@
<string name="title_advanced_sync_kept_hint">This will transfer extra data and consume extra battery power, especially if a lot of messages are stored on the device</string>
<string name="title_advanced_gmail_thread_hint">This only applies to newly received messages and can break existing groups</string>
<string name="title_advanced_sync_folders_hint">Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too</string>
<string name="title_advanced_check_authentication_hint">This will check the results of DKIM, SPF and DMARC authentication as performed by the email server</string>
<string name="title_advanced_check_reply_hint">This will check if the domain name of the sender and the reply address are the same</string>
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>