Use domain name for message IDs

pull/178/head
M66B 5 years ago
parent 0aa7addb7a
commit 121236a5d6

@ -187,7 +187,11 @@ public class EntityMessage implements Serializable {
public Long last_attempt; // send public Long last_attempt; // send
static String generateMessageId() { static String generateMessageId() {
return "<" + UUID.randomUUID() + "@localhost" + '>'; return generateMessageId("localhost");
}
static String generateMessageId(String domain) {
return "<" + UUID.randomUUID() + "@" + domain + '>';
} }
boolean replySelf(List<TupleIdentityEx> identities, long account) { boolean replySelf(List<TupleIdentityEx> identities, long account) {

@ -58,6 +58,7 @@ import javax.mail.MessageRemovedException;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.SendFailedException; import javax.mail.SendFailedException;
import javax.mail.Session; import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND; import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
@ -405,6 +406,14 @@ public class ServiceSend extends ServiceBase {
if (!message.content) if (!message.content)
throw new IllegalArgumentException("Message body missing"); throw new IllegalArgumentException("Message body missing");
// Update message ID
if (message.from != null && message.from.length > 0) {
String from = ((InternetAddress) message.from[0]).getAddress();
int at = (from == null ? -1 : from.indexOf('@'));
if (at > 0 && at + 1 < from.length())
message.msgid = EntityMessage.generateMessageId(from.substring(at + 1));
}
// Create message // Create message
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
if (ident.unicode) if (ident.unicode)

Loading…
Cancel
Save