Update message hash

This commit is contained in:
M66B 2020-04-01 12:50:15 +02:00
parent 8dcd2244b0
commit 5a1f2b4fdf
2 changed files with 17 additions and 7 deletions

View File

@ -78,7 +78,6 @@ import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -2134,12 +2133,7 @@ class Core {
if (TextUtils.isEmpty(message.msgid))
Log.w("No Message-ID id=" + message.id + " uid=" + message.uid);
try {
message.hash = Helper.sha1(helper.getHeaders().getBytes());
} catch (NoSuchAlgorithmException ex) {
Log.e(ex);
}
message.hash = helper.getHash();
message.references = TextUtils.join(" ", helper.getReferences());
message.inreplyto = helper.getInReplyTo();
// Local address contains control or whitespace in string ``mailing list someone@example.org''
@ -2418,6 +2412,12 @@ class Core {
" keywords=" + TextUtils.join(" ", keywords));
}
if (message.hash == null) {
update = true;
message.hash = helper.getHash();
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " hash=" + message.hash);
}
if (message.ui_hide &&
message.ui_snoozed == null &&
(message.ui_busy == null || message.ui_busy < new Date().getTime()) &&

View File

@ -52,6 +52,7 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -1182,6 +1183,15 @@ public class MessageHelper {
return sb.toString();
}
String getHash() throws MessagingException {
try {
return Helper.sha1(getHeaders().getBytes());
} catch (NoSuchAlgorithmException ex) {
Log.e(ex);
return null;
}
}
static String formatAddresses(Address[] addresses) {
return formatAddresses(addresses, true, false);
}