Separated reply check from warnings

pull/190/head
M66B 4 years ago
parent 76491b99ee
commit 5f46a319fc

File diff suppressed because it is too large Load Diff

@ -904,7 +904,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
!(Boolean.FALSE.equals(message.dkim) ||
Boolean.FALSE.equals(message.spf) ||
Boolean.FALSE.equals(message.dmarc) ||
Boolean.FALSE.equals(message.mx));
Boolean.FALSE.equals(message.mx) ||
Boolean.FALSE.equals(message.reply_domain));
boolean expanded = (viewType == ViewType.THREAD && properties.getValue("expanded", message.id));
// Text size
@ -3195,6 +3196,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onShowAuth(TupleMessageEx message) {
StringBuilder sb = new StringBuilder();
List<String> result = new ArrayList<>();
if (Boolean.FALSE.equals(message.dkim))
result.add("DKIM");
@ -3205,10 +3208,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (Boolean.FALSE.equals(message.mx))
result.add("MX");
ToastEx.makeText(context,
context.getString(R.string.title_authentication_failed, TextUtils.join(", ", result)),
Toast.LENGTH_LONG)
.show();
if (result.size() > 0)
sb.append(context.getString(R.string.title_authentication_failed, TextUtils.join(", ", result)));
if (Boolean.FALSE.equals(message.reply_domain)) {
if (sb.length() > 0)
sb.append('\n');
sb.append(message.checkReplyDomain(context));
}
ToastEx.makeText(context, sb.toString(), Toast.LENGTH_LONG).show();
}
private void onShowSnoozed(TupleMessageEx message) {
@ -5334,6 +5343,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
log("mx changed", next.id);
}
if (!Objects.equals(prev.reply_domain, next.reply_domain)) {
same = false;
log("reply_domain changed", next.id);
}
if (!Objects.equals(prev.avatar, next.avatar)) {
same = false;
log("avatar changed", next.id);

@ -2870,6 +2870,12 @@ class Core {
message.warning = Log.formatThrowable(ex, false);
}
boolean check_reply = prefs.getBoolean("check_reply", false);
if (check_reply) {
String warning = message.checkReplyDomain(context);
message.reply_domain = (warning == null);
}
boolean check_spam = prefs.getBoolean("check_spam", false);
if (check_spam) {
String host = helper.getReceivedFromHost();
@ -2913,16 +2919,6 @@ class Core {
}
}
boolean check_reply = prefs.getBoolean("check_reply", false);
if (check_reply) {
String warning = message.getReplyCheck(context);
if (warning != null)
if (message.warning == null)
message.warning = warning;
else
message.warning += ", " + warning;
}
try {
db.beginTransaction();

@ -64,7 +64,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 179,
version = 180,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1767,6 +1767,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `local` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(179, 180) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `reply_domain` INTEGER");
}
});
}

@ -136,7 +136,8 @@ public class EntityMessage implements Serializable {
public Boolean dkim;
public Boolean spf;
public Boolean dmarc;
public Boolean mx = null;
public Boolean mx;
public Boolean reply_domain; // differs from 'from'
public String avatar; // lookup URI from sender
public String sender; // sort key: from email address
public Address[] submitter;
@ -272,7 +273,7 @@ public class EntityMessage implements Serializable {
return false;
}
String getReplyCheck(Context context) {
String checkReplyDomain(Context context) {
if (from == null || from.length == 0)
return null;
if (reply == null || reply.length == 0)
@ -482,6 +483,7 @@ public class EntityMessage implements Serializable {
Objects.equals(this.spf, other.spf) &&
Objects.equals(this.dmarc, other.dmarc) &&
Objects.equals(this.mx, other.mx) &&
Objects.equals(this.reply_domain, other.reply_domain) &&
Objects.equals(this.avatar, other.avatar) &&
Objects.equals(this.sender, other.sender) &&
MessageHelper.equal(this.from, other.from) &&

Loading…
Cancel
Save