Support for Auto-Submitted header

pull/187/head
M66B 4 years ago
parent 06d206d491
commit b6aedc8e76

File diff suppressed because it is too large Load Diff

@ -364,6 +364,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageView ivPlain;
private ImageView ivReceipt;
private ImageView ivAutoSubmitted;
private ImageView ivBrowsed;
private ImageButton ibSearchContact;
@ -562,6 +563,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivPlain = vsBody.findViewById(R.id.ivPlain);
ivReceipt = vsBody.findViewById(R.id.ivReceipt);
ivAutoSubmitted = vsBody.findViewById(R.id.ivAutoSubmitted);
ivBrowsed = vsBody.findViewById(R.id.ivBrowsed);
ibSearchContact = vsBody.findViewById(R.id.ibSearchContact);
@ -1265,6 +1267,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivPlain.setVisibility(View.GONE);
ivReceipt.setVisibility(View.GONE);
ivAutoSubmitted.setVisibility(View.GONE);
ivBrowsed.setVisibility(View.GONE);
ibSearchContact.setVisibility(View.GONE);
@ -1683,6 +1686,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivPlain.setVisibility(show_addresses && message.plain_only != null && message.plain_only ? View.VISIBLE : View.GONE);
ivReceipt.setVisibility(message.receipt_request != null && message.receipt_request ? View.VISIBLE : View.GONE);
ivAutoSubmitted.setVisibility(message.auto_submitted != null && message.auto_submitted ? View.VISIBLE : View.GONE);
ivBrowsed.setVisibility(show_addresses && message.ui_browsed ? View.VISIBLE : View.GONE);
ibSearchContact.setVisibility(show_addresses && (froms > 0 || tos > 0) ? View.VISIBLE : View.GONE);

@ -1991,6 +1991,7 @@ class Core {
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, 0);
message.priority = helper.getPriority();
message.auto_submitted = helper.getAutoSubmitted();
message.receipt_request = helper.getReceiptRequested();
message.receipt_to = helper.getReceiptTo();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
@ -2669,6 +2670,7 @@ class Core {
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, uid);
message.priority = helper.getPriority();
message.auto_submitted = helper.getAutoSubmitted();
message.receipt_request = helper.getReceiptRequested();
message.receipt_to = helper.getReceiptTo();
message.dkim = MessageHelper.getAuthentication("dkim", authentication);

@ -62,7 +62,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 175,
version = 176,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1722,6 +1722,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `answer` ADD COLUMN `standard` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(175, 176) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `auto_submitted` INTEGER");
}
});
}

@ -129,6 +129,7 @@ public class EntityMessage implements Serializable {
public String thread; // compose = null
public Integer priority;
public Integer importance;
public Boolean auto_submitted;
public Boolean receipt; // is receipt
public Boolean receipt_request;
public Address[] receipt_to;

@ -418,6 +418,11 @@ public class EntityRule {
boolean cc = jargs.optBoolean("cc");
boolean attachments = jargs.optBoolean("attachments");
if (message.auto_submitted != null && message.auto_submitted) {
EntityLog.log(context, "Auto submitted rule=" + name);
return false;
}
if (!message.content)
EntityOperation.queue(context, message, EntityOperation.BODY);
@ -477,6 +482,7 @@ public class EntityRule {
if (cc)
reply.cc = message.cc;
reply.unsubscribe = "mailto:" + identity.email;
reply.auto_submitted = true;
reply.subject = context.getString(
TextUtils.isEmpty(to) ? R.string.title_subject_reply : R.string.title_subject_forward,
message.subject == null ? "" : message.subject);

@ -258,6 +258,9 @@ public class MessageHelper {
if (message.unsubscribe != null)
imessage.addHeader("List-Unsubscribe", "<" + message.unsubscribe + ">");
if (message.auto_submitted != null && message.auto_submitted)
imessage.addHeader("Auto-Submitted", "auto-replied");
MailDateFormat mdf = new MailDateFormat();
mdf.setTimeZone(hide_timezone ? TimeZone.getTimeZone("UTC") : TimeZone.getDefault());
imessage.setHeader("Date", mdf.format(new Date()));
@ -1049,6 +1052,14 @@ public class MessageHelper {
return priority;
}
Boolean getAutoSubmitted() throws MessagingException {
// https://tools.ietf.org/html/rfc3834
String header = imessage.getHeader("Auto-Submitted", null);
if (header == null)
return null;
return !"no".equalsIgnoreCase(header);
}
boolean getReceiptRequested() throws MessagingException {
ensureMessage(false);

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M7,11h10v2L7,13zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
</vector>

@ -279,28 +279,6 @@
app:layout_constraintStart_toEndOf="@id/ivSnoozed"
app:layout_constraintTop_toTopOf="@id/ivSnoozed" />
<ImageView
android:id="@+id/ivBrowsed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_browsed"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivSnoozed"
app:srcCompat="@drawable/twotone_playlist_add_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvBrowsed"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_browsed"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivBrowsed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivBrowsed"
app:layout_constraintTop_toTopOf="@id/ivBrowsed" />
<ImageView
android:id="@+id/ivAnswered"
android:layout_width="wrap_content"
@ -308,7 +286,7 @@
android:contentDescription="@string/title_legend_answered"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivBrowsed"
app:layout_constraintTop_toBottomOf="@id/ivSnoozed"
app:srcCompat="@drawable/twotone_reply_24" />
<eu.faircode.email.FixedTextView
@ -389,6 +367,50 @@
app:layout_constraintStart_toEndOf="@id/ivReceipt"
app:layout_constraintTop_toTopOf="@id/ivReceipt" />
<ImageView
android:id="@+id/ivAutoSubmitted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_receipt"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivReceipt"
app:srcCompat="@drawable/twotone_remove_circle_outline_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvAutoSubmitted"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_auto_submitted"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivAutoSubmitted"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivAutoSubmitted"
app:layout_constraintTop_toTopOf="@id/ivAutoSubmitted" />
<ImageView
android:id="@+id/ivBrowsed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_browsed"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivAutoSubmitted"
app:srcCompat="@drawable/twotone_playlist_add_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvBrowsed"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_browsed"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivBrowsed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivBrowsed"
app:layout_constraintTop_toTopOf="@id/ivBrowsed" />
<ImageView
android:id="@+id/ivAttachment"
android:layout_width="wrap_content"
@ -396,7 +418,7 @@
android:contentDescription="@string/title_legend_attachment"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivReceipt"
app:layout_constraintTop_toBottomOf="@id/ivBrowsed"
app:srcCompat="@drawable/twotone_attachment_24" />
<eu.faircode.email.FixedTextView
@ -418,7 +440,7 @@
android:contentDescription="@string/title_legend_flagged"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAttachment"
app:layout_constraintTop_toBottomOf="@id/ivAttachment"
app:srcCompat="@drawable/baseline_star_24" />
<eu.faircode.email.FixedTextView

@ -45,13 +45,23 @@
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
app:srcCompat="@drawable/twotone_playlist_add_check_24" />
<eu.faircode.email.ViewImageHint
android:id="@+id/ivAutoSubmitted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_auto_submitted"
app:layout_constraintStart_toEndOf="@id/ivReceipt"
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
app:srcCompat="@drawable/twotone_remove_circle_outline_24" />
<eu.faircode.email.ViewImageHint
android:id="@+id/ivBrowsed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_browsed"
app:layout_constraintStart_toEndOf="@id/ivReceipt"
app:layout_constraintStart_toEndOf="@id/ivAutoSubmitted"
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
app:srcCompat="@drawable/twotone_playlist_add_24" />
@ -108,7 +118,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="ivPlain,ivReceipt,ivBrowsed,ibSearchContact,ibNotifyContact,ibPinContact,ibAddContact" />
app:constraint_referenced_ids="ivPlain,ivReceipt,ivAutoSubmitted,ivBrowsed,ibSearchContact,ibNotifyContact,ibPinContact,ibAddContact" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSubmitterTitle"

@ -1227,6 +1227,7 @@
<string name="title_legend_forwarded">Was forwarded</string>
<string name="title_legend_plain_only">Is plain text only</string>
<string name="title_legend_receipt">Receipt was requested</string>
<string name="title_legend_auto_submitted">Was automatically sent</string>
<string name="title_legend_attachment">Has attachment</string>
<string name="title_legend_flagged">Is favorite</string>
<string name="title_legend_contacts">Manage contacts</string>

Loading…
Cancel
Save