Generate preview / detect language of encrypted messages

This commit is contained in:
M66B 2021-03-02 17:21:44 +01:00
parent 5ecb3fe03c
commit a8e2abb677
1 changed files with 34 additions and 10 deletions

View File

@ -6215,16 +6215,29 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
MessageHelper helper = new MessageHelper(imessage, context);
parts = helper.getMessageParts();
String subject = parts.getProtectedSubject();
if (subject != null)
db.message().setMessageSubject(message.id, subject);
String protect_subject = parts.getProtectedSubject();
// Write decrypted body
String html = parts.getHtml(context);
Helper.writeText(message.getFile(context), html);
Log.i("pgp html=" + (html == null ? null : html.length()));
String text = HtmlHelper.getFullText(html);
message.preview = HtmlHelper.getPreview(text);
message.language = HtmlHelper.getLanguage(context, message.subject, text);
try {
db.beginTransaction();
// Write decrypted body
String html = parts.getHtml(context);
Helper.writeText(message.getFile(context), html);
if (protect_subject != null)
db.message().setMessageSubject(message.id, protect_subject);
db.message().setMessageContent(message.id,
true,
message.language,
parts.isPlainOnly(),
message.preview,
message.warning);
// Remove existing attachments
db.attachment().deleteAttachments(message.id);
@ -6851,14 +6864,25 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
MessageHelper helper = new MessageHelper(imessage, context);
MessageHelper.MessageParts parts = helper.getMessageParts();
// Write decrypted body
String html = parts.getHtml(context);
Helper.writeText(message.getFile(context), html);
Log.i("s/mime html=" + (html == null ? null : html.length()));
String text = HtmlHelper.getFullText(html);
message.preview = HtmlHelper.getPreview(text);
message.language = HtmlHelper.getLanguage(context, message.subject, text);
DB db = DB.getInstance(context);
try {
db.beginTransaction();
// Write decrypted body
String html = parts.getHtml(context);
Helper.writeText(message.getFile(context), html);
Log.i("s/mime html=" + (html == null ? null : html.length()));
db.message().setMessageContent(message.id,
true,
message.language,
parts.isPlainOnly(),
message.preview,
message.warning);
// Remove existing attachments
db.attachment().deleteAttachments(message.id);