Send DSN to return path address

This commit is contained in:
M66B 2021-02-01 11:54:43 +01:00
parent be7d139f5d
commit c7040d1af1
7 changed files with 2387 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2148,6 +2148,7 @@ class Core {
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
message.spf = MessageHelper.getAuthentication("spf", authentication);
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.return_path = helper.getReturnPath();
message.submitter = helper.getSender();
message.from = helper.getFrom();
message.to = helper.getTo();
@ -2846,6 +2847,7 @@ class Core {
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
message.spf = MessageHelper.getAuthentication("spf", authentication);
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.return_path = helper.getReturnPath();
message.submitter = helper.getSender();
message.from = helper.getFrom();
message.to = helper.getTo();

View File

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

View File

@ -148,6 +148,7 @@ public class EntityMessage implements Serializable {
public Boolean reply_domain; // differs from 'from'
public String avatar; // lookup URI from sender
public String sender; // sort key: from email address
public Address[] return_path;
public Address[] submitter; // sent on behalf of
public Address[] from;
public Address[] to;

View File

@ -3619,9 +3619,12 @@ public class FragmentCompose extends FragmentBase {
if ("list".equals(action) && ref.list_post != null)
data.draft.to = ref.list_post;
else if ("dsn".equals(action) && ref.receipt_to != null)
data.draft.to = ref.receipt_to;
else {
else if ("dsn".equals(action)) {
if (EntityMessage.DSN_RECEIPT.equals(dsn) && ref.receipt_to != null)
data.draft.to = ref.receipt_to;
else if (EntityMessage.DSN_USER_UNKNOWN.equals(dsn) && ref.return_path != null)
data.draft.to = ref.return_path;
} else {
// Prevent replying to self
if (ref.replySelf(data.identities, ref.account)) {
data.draft.from = ref.from;

View File

@ -2431,7 +2431,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
popupMenu.getMenu().findItem(R.id.menu_reply_to_all).setVisible(recipients.length > 0);
popupMenu.getMenu().findItem(R.id.menu_reply_list).setVisible(message.list_post != null);
popupMenu.getMenu().findItem(R.id.menu_reply_receipt).setVisible(message.receipt_to != null);
popupMenu.getMenu().findItem(R.id.menu_reply_user_unknown).setVisible(experiments);
popupMenu.getMenu().findItem(R.id.menu_reply_user_unknown)
.setVisible(experiments && message.return_path != null && message.return_path.length > 0);
popupMenu.getMenu().findItem(R.id.menu_new_message).setVisible(to != null && to.length > 0);
popupMenu.getMenu().findItem(R.id.menu_reply_answer).setVisible(answers != 0 || !ActivityBilling.isPro(context));

View File

@ -1239,6 +1239,10 @@ public class MessageHelper {
return addresses;
}
Address[] getReturnPath() throws MessagingException {
return getAddressHeader("Return-Path");
}
Address[] getSender() throws MessagingException {
return getAddressHeader("Sender");
}