Selectively keep encryption parts

This commit is contained in:
M66B 2021-08-29 22:02:15 +02:00
parent 945b903312
commit 017d201f88
2 changed files with 12 additions and 7 deletions

View File

@ -140,6 +140,6 @@ public interface DaoAttachment {
@Query("DELETE FROM attachment" +
" WHERE message = :message" +
" AND encryption IS NULL")
int deleteAttachments(long message);
" AND (encryption IS NULL OR encryption NOT IN (:keep))")
int deleteAttachments(long message, int[] keep);
}

View File

@ -5959,7 +5959,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Helper.writeText(file, null);
db.message().setMessageContent(message.id, true, null, null, null, null);
//db.message().setMessageSubject(id, subject);
db.attachment().deleteAttachments(message.id);
db.attachment().deleteAttachments(message.id, new int[]{
EntityAttachment.PGP_MESSAGE,
EntityAttachment.SMIME_MESSAGE,
EntityAttachment.SMIME_SIGNED_DATA
});
db.message().setMessageEncrypt(message.id, message.ui_encrypt);
db.message().setMessageStored(message.id, new Date().getTime());
@ -6825,14 +6829,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
message.warning);
// Remove existing attachments
db.attachment().deleteAttachments(message.id);
db.attachment().deleteAttachments(message.id, new int[]{EntityAttachment.PGP_MESSAGE});
// Add decrypted attachments
List<EntityAttachment> remotes = parts.getAttachments();
for (int index = 0; index < remotes.size(); index++) {
EntityAttachment remote = remotes.get(index);
if (remote.encryption != null)
continue;
remote.message = message.id;
remote.sequence = index + 1;
remote.id = db.attachment().insertAttachment(remote);
@ -7486,7 +7488,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
message.warning);
// Remove existing attachments
db.attachment().deleteAttachments(message.id);
db.attachment().deleteAttachments(message.id, new int[]{
EntityAttachment.SMIME_MESSAGE,
EntityAttachment.SMIME_SIGNED_DATA
});
// Add decrypted attachments
List<EntityAttachment> remotes = parts.getAttachments();