mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add RecipientStore to resolve all identifiers to SignalServiceAddress
Should fix #290
This commit is contained in:
parent
d49d536c32
commit
320e126eeb
8 changed files with 174 additions and 16 deletions
|
@ -139,6 +139,7 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
@ -1287,7 +1288,10 @@ public class Manager implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupInfo.getMembers().isPresent()) {
|
if (groupInfo.getMembers().isPresent()) {
|
||||||
group.addMembers(groupInfo.getMembers().get());
|
group.addMembers(groupInfo.getMembers().get()
|
||||||
|
.stream()
|
||||||
|
.map(this::resolveSignalServiceAddress)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
account.getGroupStore().updateGroup(group);
|
account.getGroupStore().updateGroup(group);
|
||||||
|
@ -1326,8 +1330,9 @@ public class Manager implements Signal {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final SignalServiceAddress conversationPartnerAddress = isSync ? destination : source;
|
||||||
if (message.isEndSession()) {
|
if (message.isEndSession()) {
|
||||||
handleEndSession(isSync ? destination : source);
|
handleEndSession(conversationPartnerAddress);
|
||||||
}
|
}
|
||||||
if (message.isExpirationUpdate() || message.getBody().isPresent()) {
|
if (message.isExpirationUpdate() || message.getBody().isPresent()) {
|
||||||
if (message.getGroupContext().isPresent() && message.getGroupContext().get().getGroupV1().isPresent()) {
|
if (message.getGroupContext().isPresent() && message.getGroupContext().get().getGroupV1().isPresent()) {
|
||||||
|
@ -1341,9 +1346,9 @@ public class Manager implements Signal {
|
||||||
account.getGroupStore().updateGroup(group);
|
account.getGroupStore().updateGroup(group);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ContactInfo contact = account.getContactStore().getContact(isSync ? destination : source);
|
ContactInfo contact = account.getContactStore().getContact(conversationPartnerAddress);
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
contact = new ContactInfo(isSync ? destination : source);
|
contact = new ContactInfo(conversationPartnerAddress);
|
||||||
}
|
}
|
||||||
if (contact.messageExpirationTime != message.getExpiresInSeconds()) {
|
if (contact.messageExpirationTime != message.getExpiresInSeconds()) {
|
||||||
contact.messageExpirationTime = message.getExpiresInSeconds();
|
contact.messageExpirationTime = message.getExpiresInSeconds();
|
||||||
|
@ -1607,7 +1612,10 @@ public class Manager implements Signal {
|
||||||
if (g.getName().isPresent()) {
|
if (g.getName().isPresent()) {
|
||||||
syncGroup.name = g.getName().get();
|
syncGroup.name = g.getName().get();
|
||||||
}
|
}
|
||||||
syncGroup.addMembers(g.getMembers());
|
syncGroup.addMembers(g.getMembers()
|
||||||
|
.stream()
|
||||||
|
.map(this::resolveSignalServiceAddress)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
if (!g.isActive()) {
|
if (!g.isActive()) {
|
||||||
syncGroup.removeMember(account.getSelfAddress());
|
syncGroup.removeMember(account.getSelfAddress());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1642,7 +1650,7 @@ public class Manager implements Signal {
|
||||||
if (syncMessage.getBlockedList().isPresent()) {
|
if (syncMessage.getBlockedList().isPresent()) {
|
||||||
final BlockedListMessage blockedListMessage = syncMessage.getBlockedList().get();
|
final BlockedListMessage blockedListMessage = syncMessage.getBlockedList().get();
|
||||||
for (SignalServiceAddress address : blockedListMessage.getAddresses()) {
|
for (SignalServiceAddress address : blockedListMessage.getAddresses()) {
|
||||||
setContactBlocked(address, true);
|
setContactBlocked(resolveSignalServiceAddress(address), true);
|
||||||
}
|
}
|
||||||
for (byte[] groupId : blockedListMessage.getGroupIds()) {
|
for (byte[] groupId : blockedListMessage.getGroupIds()) {
|
||||||
try {
|
try {
|
||||||
|
@ -1667,9 +1675,10 @@ public class Manager implements Signal {
|
||||||
if (c.getAddress().matches(account.getSelfAddress()) && c.getProfileKey().isPresent()) {
|
if (c.getAddress().matches(account.getSelfAddress()) && c.getProfileKey().isPresent()) {
|
||||||
account.setProfileKey(c.getProfileKey().get());
|
account.setProfileKey(c.getProfileKey().get());
|
||||||
}
|
}
|
||||||
ContactInfo contact = account.getContactStore().getContact(c.getAddress());
|
final SignalServiceAddress address = resolveSignalServiceAddress(c.getAddress());
|
||||||
|
ContactInfo contact = account.getContactStore().getContact(address);
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
contact = new ContactInfo(c.getAddress());
|
contact = new ContactInfo(address);
|
||||||
}
|
}
|
||||||
if (c.getName().isPresent()) {
|
if (c.getName().isPresent()) {
|
||||||
contact.name = c.getName().get();
|
contact.name = c.getName().get();
|
||||||
|
@ -1711,7 +1720,7 @@ public class Manager implements Signal {
|
||||||
}
|
}
|
||||||
if (syncMessage.getVerified().isPresent()) {
|
if (syncMessage.getVerified().isPresent()) {
|
||||||
final VerifiedMessage verifiedMessage = syncMessage.getVerified().get();
|
final VerifiedMessage verifiedMessage = syncMessage.getVerified().get();
|
||||||
account.getSignalProtocolStore().setIdentityTrustLevel(verifiedMessage.getDestination(), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
|
account.getSignalProtocolStore().setIdentityTrustLevel(resolveSignalServiceAddress(verifiedMessage.getDestination()), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
|
||||||
}
|
}
|
||||||
if (syncMessage.getConfiguration().isPresent()) {
|
if (syncMessage.getConfiguration().isPresent()) {
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -2030,15 +2039,16 @@ public class Manager implements Signal {
|
||||||
|
|
||||||
public SignalServiceAddress resolveSignalServiceAddress(String identifier) {
|
public SignalServiceAddress resolveSignalServiceAddress(String identifier) {
|
||||||
SignalServiceAddress address = Util.getSignalServiceAddressFromIdentifier(identifier);
|
SignalServiceAddress address = Util.getSignalServiceAddressFromIdentifier(identifier);
|
||||||
|
|
||||||
|
return resolveSignalServiceAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SignalServiceAddress resolveSignalServiceAddress(SignalServiceAddress address) {
|
||||||
if (address.matches(account.getSelfAddress())) {
|
if (address.matches(account.getSelfAddress())) {
|
||||||
return account.getSelfAddress();
|
return account.getSelfAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactInfo contactInfo = account.getContactStore().getContact(address);
|
return account.getRecipientStore().resolveServiceAddress(address);
|
||||||
if (contactInfo == null) {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
return contactInfo.getAddress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ReceiveMessageHandler {
|
public interface ReceiveMessageHandler {
|
||||||
|
|
|
@ -252,6 +252,9 @@ class Utils {
|
||||||
} else {
|
} else {
|
||||||
// Version 1: E164 user
|
// Version 1: E164 user
|
||||||
version = 1;
|
version = 1;
|
||||||
|
if (!ownAddress.getNumber().isPresent() || !theirAddress.getNumber().isPresent()) {
|
||||||
|
return "INVALID ID";
|
||||||
|
}
|
||||||
ownId = ownAddress.getNumber().get().getBytes();
|
ownId = ownAddress.getNumber().get().getBytes();
|
||||||
theirId = theirAddress.getNumber().get().getBytes();
|
theirId = theirAddress.getNumber().get().getBytes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,10 @@ import org.asamk.signal.storage.contacts.ContactInfo;
|
||||||
import org.asamk.signal.storage.contacts.JsonContactsStore;
|
import org.asamk.signal.storage.contacts.JsonContactsStore;
|
||||||
import org.asamk.signal.storage.groups.GroupInfo;
|
import org.asamk.signal.storage.groups.GroupInfo;
|
||||||
import org.asamk.signal.storage.groups.JsonGroupStore;
|
import org.asamk.signal.storage.groups.JsonGroupStore;
|
||||||
|
import org.asamk.signal.storage.protocol.JsonIdentityKeyStore;
|
||||||
import org.asamk.signal.storage.protocol.JsonSignalProtocolStore;
|
import org.asamk.signal.storage.protocol.JsonSignalProtocolStore;
|
||||||
|
import org.asamk.signal.storage.protocol.RecipientStore;
|
||||||
|
import org.asamk.signal.storage.protocol.SessionInfo;
|
||||||
import org.asamk.signal.storage.protocol.SignalServiceAddressResolver;
|
import org.asamk.signal.storage.protocol.SignalServiceAddressResolver;
|
||||||
import org.asamk.signal.storage.threads.LegacyJsonThreadStore;
|
import org.asamk.signal.storage.threads.LegacyJsonThreadStore;
|
||||||
import org.asamk.signal.storage.threads.ThreadInfo;
|
import org.asamk.signal.storage.threads.ThreadInfo;
|
||||||
|
@ -37,6 +40,7 @@ import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.FileLock;
|
import java.nio.channels.FileLock;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SignalAccount {
|
public class SignalAccount {
|
||||||
|
|
||||||
|
@ -59,6 +63,7 @@ public class SignalAccount {
|
||||||
private JsonSignalProtocolStore signalProtocolStore;
|
private JsonSignalProtocolStore signalProtocolStore;
|
||||||
private JsonGroupStore groupStore;
|
private JsonGroupStore groupStore;
|
||||||
private JsonContactsStore contactStore;
|
private JsonContactsStore contactStore;
|
||||||
|
private RecipientStore recipientStore;
|
||||||
|
|
||||||
private SignalAccount() {
|
private SignalAccount() {
|
||||||
jsonProcessor.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); // disable autodetect
|
jsonProcessor.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); // disable autodetect
|
||||||
|
@ -88,6 +93,7 @@ public class SignalAccount {
|
||||||
account.signalProtocolStore = new JsonSignalProtocolStore(identityKey, registrationId);
|
account.signalProtocolStore = new JsonSignalProtocolStore(identityKey, registrationId);
|
||||||
account.groupStore = new JsonGroupStore();
|
account.groupStore = new JsonGroupStore();
|
||||||
account.contactStore = new JsonContactsStore();
|
account.contactStore = new JsonContactsStore();
|
||||||
|
account.recipientStore = new RecipientStore();
|
||||||
account.registered = false;
|
account.registered = false;
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
|
@ -108,6 +114,7 @@ public class SignalAccount {
|
||||||
account.signalProtocolStore = new JsonSignalProtocolStore(identityKey, registrationId);
|
account.signalProtocolStore = new JsonSignalProtocolStore(identityKey, registrationId);
|
||||||
account.groupStore = new JsonGroupStore();
|
account.groupStore = new JsonGroupStore();
|
||||||
account.contactStore = new JsonContactsStore();
|
account.contactStore = new JsonContactsStore();
|
||||||
|
account.recipientStore = new RecipientStore();
|
||||||
account.registered = true;
|
account.registered = true;
|
||||||
account.isMultiDevice = true;
|
account.isMultiDevice = true;
|
||||||
|
|
||||||
|
@ -199,6 +206,35 @@ public class SignalAccount {
|
||||||
if (contactStore == null) {
|
if (contactStore == null) {
|
||||||
contactStore = new JsonContactsStore();
|
contactStore = new JsonContactsStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonNode recipientStoreNode = rootNode.get("recipientStore");
|
||||||
|
if (recipientStoreNode != null) {
|
||||||
|
recipientStore = jsonProcessor.convertValue(recipientStoreNode, RecipientStore.class);
|
||||||
|
}
|
||||||
|
if (recipientStore == null) {
|
||||||
|
recipientStore = new RecipientStore();
|
||||||
|
|
||||||
|
recipientStore.resolveServiceAddress(getSelfAddress());
|
||||||
|
|
||||||
|
for (ContactInfo contact : contactStore.getContacts()) {
|
||||||
|
recipientStore.resolveServiceAddress(contact.getAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GroupInfo group : groupStore.getGroups()) {
|
||||||
|
group.members = group.members.stream()
|
||||||
|
.map(m -> recipientStore.resolveServiceAddress(m))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SessionInfo session : signalProtocolStore.getSessions()) {
|
||||||
|
session.address = recipientStore.resolveServiceAddress(session.address);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (JsonIdentityKeyStore.Identity identity : signalProtocolStore.getIdentities()) {
|
||||||
|
identity.setAddress(recipientStore.resolveServiceAddress(identity.getAddress()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JsonNode threadStoreNode = rootNode.get("threadStore");
|
JsonNode threadStoreNode = rootNode.get("threadStore");
|
||||||
if (threadStoreNode != null) {
|
if (threadStoreNode != null) {
|
||||||
LegacyJsonThreadStore threadStore = jsonProcessor.convertValue(threadStoreNode, LegacyJsonThreadStore.class);
|
LegacyJsonThreadStore threadStore = jsonProcessor.convertValue(threadStoreNode, LegacyJsonThreadStore.class);
|
||||||
|
@ -244,6 +280,7 @@ public class SignalAccount {
|
||||||
.putPOJO("axolotlStore", signalProtocolStore)
|
.putPOJO("axolotlStore", signalProtocolStore)
|
||||||
.putPOJO("groupStore", groupStore)
|
.putPOJO("groupStore", groupStore)
|
||||||
.putPOJO("contactStore", contactStore)
|
.putPOJO("contactStore", contactStore)
|
||||||
|
.putPOJO("recipientStore", recipientStore)
|
||||||
;
|
;
|
||||||
try {
|
try {
|
||||||
synchronized (fileChannel) {
|
synchronized (fileChannel) {
|
||||||
|
@ -302,6 +339,10 @@ public class SignalAccount {
|
||||||
return contactStore;
|
return contactStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RecipientStore getRecipientStore() {
|
||||||
|
return recipientStore;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,12 @@ public class JsonContactsStore {
|
||||||
public ContactInfo getContact(SignalServiceAddress address) {
|
public ContactInfo getContact(SignalServiceAddress address) {
|
||||||
for (ContactInfo contact : contacts) {
|
for (ContactInfo contact : contacts) {
|
||||||
if (contact.getAddress().matches(address)) {
|
if (contact.getAddress().matches(address)) {
|
||||||
|
if (contact.uuid == null) {
|
||||||
|
contact.uuid = address.getUuid().orNull();
|
||||||
|
} else if (contact.number == null) {
|
||||||
|
contact.number = address.getNumber().orNull();
|
||||||
|
}
|
||||||
|
|
||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,9 @@ public class GroupInfo {
|
||||||
|
|
||||||
public void addMembers(Collection<SignalServiceAddress> addresses) {
|
public void addMembers(Collection<SignalServiceAddress> addresses) {
|
||||||
for (SignalServiceAddress address : addresses) {
|
for (SignalServiceAddress address : addresses) {
|
||||||
|
if (this.members.contains(address)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
removeMember(address);
|
removeMember(address);
|
||||||
this.members.add(address);
|
this.members.add(address);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,10 @@ class JsonSessionStore implements SessionStore {
|
||||||
return new SessionRecord();
|
return new SessionRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized List<SessionInfo> getSessions() {
|
||||||
|
return sessions;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<Integer> getSubDeviceSessions(String name) {
|
public synchronized List<Integer> getSubDeviceSessions(String name) {
|
||||||
SignalServiceAddress serviceAddress = resolveSignalServiceAddress(name);
|
SignalServiceAddress serviceAddress = resolveSignalServiceAddress(name);
|
||||||
|
@ -158,7 +162,7 @@ class JsonSessionStore implements SessionStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JsonPreKeyStoreSerializer extends JsonSerializer<JsonSessionStore> {
|
public static class JsonSessionStoreSerializer extends JsonSerializer<JsonSessionStore> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(JsonSessionStore jsonSessionStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
|
public void serialize(JsonSessionStore jsonSessionStore, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
||||||
|
|
||||||
@JsonProperty("sessionStore")
|
@JsonProperty("sessionStore")
|
||||||
@JsonDeserialize(using = JsonSessionStore.JsonSessionStoreDeserializer.class)
|
@JsonDeserialize(using = JsonSessionStore.JsonSessionStoreDeserializer.class)
|
||||||
@JsonSerialize(using = JsonSessionStore.JsonPreKeyStoreSerializer.class)
|
@JsonSerialize(using = JsonSessionStore.JsonSessionStoreSerializer.class)
|
||||||
private JsonSessionStore sessionStore;
|
private JsonSessionStore sessionStore;
|
||||||
|
|
||||||
@JsonProperty("signedPreKeyStore")
|
@JsonProperty("signedPreKeyStore")
|
||||||
|
@ -131,6 +131,10 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
||||||
return sessionStore.loadSession(address);
|
return sessionStore.loadSession(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SessionInfo> getSessions() {
|
||||||
|
return sessionStore.getSessions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> getSubDeviceSessions(String name) {
|
public List<Integer> getSubDeviceSessions(String name) {
|
||||||
return sessionStore.getSubDeviceSessions(name);
|
return sessionStore.getSubDeviceSessions(name);
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package org.asamk.signal.storage.protocol;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class RecipientStore {
|
||||||
|
|
||||||
|
@JsonProperty("recipientStore")
|
||||||
|
@JsonDeserialize(using = RecipientStoreDeserializer.class)
|
||||||
|
@JsonSerialize(using = RecipientStoreSerializer.class)
|
||||||
|
private final Set<SignalServiceAddress> addresses = new HashSet<>();
|
||||||
|
|
||||||
|
public RecipientStore() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SignalServiceAddress resolveServiceAddress(SignalServiceAddress serviceAddress) {
|
||||||
|
if (addresses.contains(serviceAddress)) {
|
||||||
|
// If the Set already contains the exact address with UUID and Number,
|
||||||
|
// we can just return it here.
|
||||||
|
return serviceAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SignalServiceAddress address : addresses) {
|
||||||
|
if (address.matches(serviceAddress)) {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceAddress.getNumber().isPresent() && serviceAddress.getUuid().isPresent()) {
|
||||||
|
addresses.add(serviceAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return serviceAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RecipientStoreDeserializer extends JsonDeserializer<Set<SignalServiceAddress>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<SignalServiceAddress> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||||
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
Set<SignalServiceAddress> addresses = new HashSet<>();
|
||||||
|
|
||||||
|
if (node.isArray()) {
|
||||||
|
for (JsonNode recipient : node) {
|
||||||
|
String recipientName = recipient.get("name").asText();
|
||||||
|
UUID uuid = UuidUtil.parseOrThrow(recipient.get("uuid").asText());
|
||||||
|
final SignalServiceAddress serviceAddress = new SignalServiceAddress(uuid, recipientName);
|
||||||
|
addresses.add(serviceAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return addresses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RecipientStoreSerializer extends JsonSerializer<Set<SignalServiceAddress>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(Set<SignalServiceAddress> addresses, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
|
||||||
|
json.writeStartArray();
|
||||||
|
for (SignalServiceAddress address : addresses) {
|
||||||
|
json.writeStartObject();
|
||||||
|
json.writeStringField("name", address.getNumber().get());
|
||||||
|
json.writeStringField("uuid", address.getUuid().get().toString());
|
||||||
|
json.writeEndObject();
|
||||||
|
}
|
||||||
|
json.writeEndArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue