Added decryption of PGP subject header

pull/187/head
M66B 4 years ago
parent e4adc92ddc
commit 25b8f21e06

@ -617,6 +617,9 @@ public interface DaoMessage {
@Query("UPDATE message SET received = :received WHERE id = :id")
int setMessageReceived(long id, long received);
@Query("UPDATE message SET subject = :subject WHERE id = :id")
int setMessageSubject(long id, String subject);
@Query("UPDATE message SET seen = :seen WHERE id = :id")
int setMessageSeen(long id, boolean seen);

@ -201,11 +201,14 @@ import java.util.Objects;
import java.util.Properties;
import javax.mail.Address;
import javax.mail.BodyPart;
import javax.mail.MessageRemovedException;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.ContentType;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import me.everything.android.ui.overscroll.IOverScrollDecor;
import me.everything.android.ui.overscroll.IOverScrollUpdateListener;
@ -5968,6 +5971,25 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
MimeMessage imessage = new MimeMessage(isession, fis);
MessageHelper helper = new MessageHelper(imessage, context);
parts = helper.getMessageParts();
// https://github.com/autocrypt/protected-headers
try {
Object content = imessage.getContent();
if (content instanceof MimeMultipart) {
MimeMultipart mmp = (MimeMultipart) content;
if (mmp.getCount() > 0) {
BodyPart bp = mmp.getBodyPart(0);
ContentType ct = new ContentType(bp.getContentType());
if ("v1".equals(ct.getParameter("protected-headers"))) {
String[] subject = bp.getHeader("subject");
if (subject != null && subject.length != 0)
db.message().setMessageSubject(message.id, subject[0]);
}
}
}
} catch (Throwable ex) {
Log.e(ex);
}
}
try {

Loading…
Cancel
Save