Check raw message ID

This commit is contained in:
M66B 2023-06-02 17:48:36 +02:00
parent 0be53b81a0
commit 03e2d05539
1 changed files with 14 additions and 2 deletions

View File

@ -494,7 +494,7 @@ class Core {
break;
case EntityOperation.RAW:
onRaw(context, jargs, folder, message, (IMAPFolder) ifolder);
onRaw(context, jargs, account, folder, message, (IMAPFolder) ifolder);
break;
case EntityOperation.BODY:
@ -1935,7 +1935,7 @@ class Core {
db.message().setMessageHeaders(message.id, helper.getHeaders());
}
private static void onRaw(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException, IOException, JSONException {
private static void onRaw(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException, IOException, JSONException {
// Download raw message
DB db = DB.getInstance(context);
@ -1950,6 +1950,18 @@ class Core {
imessage.writeTo(os);
}
Properties props = MessageHelper.getSessionProperties(account.unicode);
Session isession = Session.getInstance(props, null);
MessageHelper helper;
try (InputStream is = new FileInputStream(file)) {
helper = new MessageHelper(new MimeMessage(isession, is), context);
}
// Yahoo is returning incorrect messages
if (!Objects.equals(message.msgid, helper.getMessageID()))
throw new MessagingException("Incorrect msgid=" + message.msgid + "/" + helper.getMessageID());
db.message().setMessageRaw(message.id, true);
}