Fix NoSuchElementException in json serialization for messages from an untrusted identity

Fixes #910
This commit is contained in:
AsamK 2022-03-16 19:37:58 +01:00
parent 90df362c35
commit 3c2fa65e05

View file

@ -3,9 +3,9 @@ package org.asamk.signal.json;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.UntrustedIdentityException;
import org.asamk.signal.manager.api.MessageEnvelope; import org.asamk.signal.manager.api.MessageEnvelope;
import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.UntrustedIdentityException;
import org.asamk.signal.manager.storage.recipients.RecipientAddress; import org.asamk.signal.manager.storage.recipients.RecipientAddress;
import java.util.UUID; import java.util.UUID;
@ -48,8 +48,7 @@ public record JsonMessageEnvelope(
source = sourceAddress.getLegacyIdentifier(); source = sourceAddress.getLegacyIdentifier();
sourceNumber = sourceAddress.number().orElse(null); sourceNumber = sourceAddress.number().orElse(null);
sourceUuid = sourceAddress.uuid().map(UUID::toString).orElse(null); sourceUuid = sourceAddress.uuid().map(UUID::toString).orElse(null);
sourceName = m.getContactOrProfileName(RecipientIdentifier.Single.fromAddress(envelope.sourceAddress() sourceName = m.getContactOrProfileName(RecipientIdentifier.Single.fromAddress(sourceAddress));
.get()));
} else { } else {
source = null; source = null;
sourceNumber = null; sourceNumber = null;