Decode Sensitivity header

This commit is contained in:
M66B 2022-01-18 10:07:13 +01:00
parent 4977d372e8
commit e71f92c938
6 changed files with 2740 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6396,6 +6396,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
log("ui_importance changed", next.id);
}
if (!Objects.equals(prev.sensitivity, next.sensitivity)) {
same = false;
log("sensitivity changed", next.id);
}
if (!Objects.equals(prev.receipt_request, next.receipt_request)) {
same = false;
log("receipt_request changed", next.id);

View File

@ -2852,6 +2852,7 @@ class Core {
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, folder.id, 0);
message.priority = helper.getPriority();
message.sensitivity = helper.getSensitivity();
message.auto_submitted = helper.getAutoSubmitted();
message.receipt_request = helper.getReceiptRequested();
message.receipt_to = helper.getReceiptTo();
@ -3833,6 +3834,7 @@ class Core {
if (BuildConfig.DEBUG && message.thread.startsWith("outlook:"))
message.warning = message.thread;
message.priority = helper.getPriority();
message.sensitivity = helper.getSensitivity();
for (String keyword : keywords)
if (MessageHelper.FLAG_LOW_IMPORTANCE.equals(keyword))

View File

@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 220,
version = 221,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2239,6 +2239,12 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `tls` INTEGER");
}
}).addMigrations(new Migration(220, 221) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `sensitivity` INTEGER");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

View File

@ -104,6 +104,10 @@ public class EntityMessage implements Serializable {
static final Integer PRIORITIY_NORMAL = 1;
static final Integer PRIORITIY_HIGH = 2;
static final Integer SENSITIVITY_PERSONAL = 1;
static final Integer SENSITIVITY_PRIVATE = 2;
static final Integer SENSITIVITY_CONFIDENTIAL = 3;
static final Integer DSN_NONE = 0;
static final Integer DSN_RECEIPT = 1;
static final Integer DSN_HARD_BOUNCE = 2;
@ -139,6 +143,7 @@ public class EntityMessage implements Serializable {
public String thread; // compose = null
public Integer priority;
public Integer importance;
public Integer sensitivity;
public Boolean auto_submitted;
@ColumnInfo(name = "receipt")
public Integer dsn;
@ -562,6 +567,8 @@ public class EntityMessage implements Serializable {
Objects.equals(this.wasforwardedfrom, other.wasforwardedfrom) &&
Objects.equals(this.thread, other.thread) &&
Objects.equals(this.priority, other.priority) &&
Objects.equals(this.importance, other.importance) &&
Objects.equals(this.sensitivity, other.sensitivity) &&
Objects.equals(this.dsn, other.dsn) &&
Objects.equals(this.receipt_request, other.receipt_request) &&
MessageHelper.equal(this.receipt_to, other.receipt_to) &&

View File

@ -1583,6 +1583,27 @@ public class MessageHelper {
return priority;
}
Integer getSensitivity() throws MessagingException {
ensureHeaders();
// https://www.rfc-editor.org/rfc/rfc4021.html#section-2.1.55
String header = imessage.getHeader("Sensitivity", null);
if (TextUtils.isEmpty(header))
return null;
header = header.toLowerCase(Locale.ROOT);
if (header.contains("personal"))
return EntityMessage.SENSITIVITY_PERSONAL;
if (header.contains("private"))
return EntityMessage.SENSITIVITY_PRIVATE;
if (header.contains("company")) // company-confidential
return EntityMessage.SENSITIVITY_CONFIDENTIAL;
return null;
}
Boolean getAutoSubmitted() throws MessagingException {
// https://tools.ietf.org/html/rfc3834
String header = imessage.getHeader("Auto-Submitted", null);