mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update libsignal-service-java
This commit is contained in:
parent
510dc89e92
commit
a20bbe1246
18 changed files with 106 additions and 99 deletions
|
@ -2459,6 +2459,10 @@
|
||||||
{"name":"metadata_"}
|
{"name":"metadata_"}
|
||||||
]}
|
]}
|
||||||
,
|
,
|
||||||
|
{
|
||||||
|
"name":"org.whispersystems.signalservice.internal.util.JsonUtil$AciDeserializer",
|
||||||
|
"methods":[{"name":"<init>","parameterTypes":[] }]}
|
||||||
|
,
|
||||||
{
|
{
|
||||||
"name":"org.whispersystems.signalservice.internal.util.JsonUtil$IdentityKeyDeserializer",
|
"name":"org.whispersystems.signalservice.internal.util.JsonUtil$IdentityKeyDeserializer",
|
||||||
"methods":[{"name":"<init>","parameterTypes":[] }]}
|
"methods":[{"name":"<init>","parameterTypes":[] }]}
|
||||||
|
|
|
@ -14,9 +14,9 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.github.turasa:signal-service-java:2.15.3_unofficial_31")
|
implementation("com.github.turasa:signal-service-java:2.15.3_unofficial_32")
|
||||||
api("com.fasterxml.jackson.core", "jackson-databind", "2.13.0")
|
api("com.fasterxml.jackson.core", "jackson-databind", "2.13.0")
|
||||||
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
implementation("com.google.protobuf:protobuf-javalite:3.11.4")
|
||||||
implementation("org.bouncycastle:bcprov-jdk15on:1.69")
|
implementation("org.bouncycastle:bcprov-jdk15on:1.69")
|
||||||
implementation("org.slf4j:slf4j-api:1.7.32")
|
implementation("org.slf4j:slf4j-api:1.7.32")
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class AvatarStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLegacyIdentifier(final SignalServiceAddress address) {
|
private String getLegacyIdentifier(final SignalServiceAddress address) {
|
||||||
return address.getNumber().or(() -> address.getUuid().toString());
|
return address.getNumber().or(() -> address.getAci().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getProfileAvatarFile(SignalServiceAddress address) {
|
private File getProfileAvatarFile(SignalServiceAddress address) {
|
||||||
|
|
|
@ -74,6 +74,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
|
@ -149,7 +150,7 @@ public class ManagerImpl implements Manager {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.serviceEnvironmentConfig = serviceEnvironmentConfig;
|
this.serviceEnvironmentConfig = serviceEnvironmentConfig;
|
||||||
|
|
||||||
final var credentialsProvider = new DynamicCredentialsProvider(account.getUuid(),
|
final var credentialsProvider = new DynamicCredentialsProvider(account.getAci(),
|
||||||
account.getUsername(),
|
account.getUsername(),
|
||||||
account.getPassword(),
|
account.getPassword(),
|
||||||
account.getDeviceId());
|
account.getDeviceId());
|
||||||
|
@ -262,8 +263,8 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preKeyHelper.refreshPreKeysIfNecessary();
|
preKeyHelper.refreshPreKeysIfNecessary();
|
||||||
if (account.getUuid() == null) {
|
if (account.getAci() == null) {
|
||||||
account.setUuid(dependencies.getAccountManager().getOwnUuid());
|
account.setAci(dependencies.getAccountManager().getOwnAci());
|
||||||
}
|
}
|
||||||
updateAccountAttributes(null);
|
updateAccountAttributes(null);
|
||||||
}
|
}
|
||||||
|
@ -293,8 +294,8 @@ public class ManagerImpl implements Manager {
|
||||||
|
|
||||||
return numbers.stream().collect(Collectors.toMap(n -> n, n -> {
|
return numbers.stream().collect(Collectors.toMap(n -> n, n -> {
|
||||||
final var number = canonicalizedNumbers.get(n);
|
final var number = canonicalizedNumbers.get(n);
|
||||||
final var uuid = registeredUsers.get(number);
|
final var aci = registeredUsers.get(number);
|
||||||
return new Pair<>(number.isEmpty() ? null : number, uuid);
|
return new Pair<>(number.isEmpty() ? null : number, aci == null ? null : aci.uuid());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,22 +818,22 @@ public class ManagerImpl implements Manager {
|
||||||
return resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
|
return resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID getRegisteredUser(final String number) throws IOException {
|
private ACI getRegisteredUser(final String number) throws IOException {
|
||||||
final Map<String, UUID> uuidMap;
|
final Map<String, ACI> aciMap;
|
||||||
try {
|
try {
|
||||||
uuidMap = getRegisteredUsers(Set.of(number));
|
aciMap = getRegisteredUsers(Set.of(number));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IOException(number, e);
|
throw new IOException(number, e);
|
||||||
}
|
}
|
||||||
final var uuid = uuidMap.get(number);
|
final var uuid = aciMap.get(number);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
throw new IOException(number, null);
|
throw new IOException(number, null);
|
||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, UUID> getRegisteredUsers(final Set<String> numbers) throws IOException {
|
private Map<String, ACI> getRegisteredUsers(final Set<String> numbers) throws IOException {
|
||||||
final Map<String, UUID> registeredUsers;
|
final Map<String, ACI> registeredUsers;
|
||||||
try {
|
try {
|
||||||
registeredUsers = dependencies.getAccountManager()
|
registeredUsers = dependencies.getAccountManager()
|
||||||
.getRegisteredUsers(ServiceConfig.getIasKeyStore(),
|
.getRegisteredUsers(ServiceConfig.getIasKeyStore(),
|
||||||
|
@ -842,8 +843,8 @@ public class ManagerImpl implements Manager {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store numbers as recipients so we have the number/uuid association
|
// Store numbers as recipients, so we have the number/uuid association
|
||||||
registeredUsers.forEach((number, uuid) -> resolveRecipientTrusted(new SignalServiceAddress(uuid, number)));
|
registeredUsers.forEach((number, aci) -> resolveRecipientTrusted(new SignalServiceAddress(aci, number)));
|
||||||
|
|
||||||
return registeredUsers;
|
return registeredUsers;
|
||||||
}
|
}
|
||||||
|
@ -1313,15 +1314,15 @@ public class ManagerImpl implements Manager {
|
||||||
// Address in recipient store doesn't have a uuid, this shouldn't happen
|
// Address in recipient store doesn't have a uuid, this shouldn't happen
|
||||||
// Try to retrieve the uuid from the server
|
// Try to retrieve the uuid from the server
|
||||||
final var number = address.getNumber().get();
|
final var number = address.getNumber().get();
|
||||||
final UUID uuid;
|
final ACI aci;
|
||||||
try {
|
try {
|
||||||
uuid = getRegisteredUser(number);
|
aci = getRegisteredUser(number);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Failed to get uuid for e164 number: {}", number, e);
|
logger.warn("Failed to get uuid for e164 number: {}", number, e);
|
||||||
// Return SignalServiceAddress with unknown UUID
|
// Return SignalServiceAddress with unknown UUID
|
||||||
return address.toSignalServiceAddress();
|
return address.toSignalServiceAddress();
|
||||||
}
|
}
|
||||||
return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(uuid));
|
return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(aci));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
|
private Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
|
||||||
|
@ -1334,8 +1335,8 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
private RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
||||||
if (recipient instanceof RecipientIdentifier.Uuid) {
|
if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
|
||||||
return account.getRecipientStore().resolveRecipient(((RecipientIdentifier.Uuid) recipient).uuid());
|
return account.getRecipientStore().resolveRecipient(ACI.from(uuidRecipient.uuid()));
|
||||||
} else {
|
} else {
|
||||||
final var number = ((RecipientIdentifier.Number) recipient).number();
|
final var number = ((RecipientIdentifier.Number) recipient).number();
|
||||||
return account.getRecipientStore().resolveRecipient(number, () -> {
|
return account.getRecipientStore().resolveRecipient(number, () -> {
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class ProvisioningManager {
|
||||||
try {
|
try {
|
||||||
account = SignalAccount.createOrUpdateLinkedAccount(pathConfig.dataPath(),
|
account = SignalAccount.createOrUpdateLinkedAccount(pathConfig.dataPath(),
|
||||||
number,
|
number,
|
||||||
ret.getUuid(),
|
ret.getAci(),
|
||||||
password,
|
password,
|
||||||
encryptedDeviceName,
|
encryptedDeviceName,
|
||||||
deviceId,
|
deviceId,
|
||||||
|
|
|
@ -37,8 +37,8 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations;
|
import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
|
||||||
import org.whispersystems.signalservice.internal.ServiceResponse;
|
import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||||
import org.whispersystems.signalservice.internal.push.LockedException;
|
import org.whispersystems.signalservice.internal.push.LockedException;
|
||||||
import org.whispersystems.signalservice.internal.push.RequestVerificationCodeResponse;
|
import org.whispersystems.signalservice.internal.push.RequestVerificationCodeResponse;
|
||||||
|
@ -190,7 +190,7 @@ public class RegistrationManager implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
||||||
account.finishRegistration(UuidUtil.parseOrNull(response.getUuid()), masterKey, pin);
|
account.finishRegistration(ACI.parseOrNull(response.getUuid()), masterKey, pin);
|
||||||
|
|
||||||
ManagerImpl m = null;
|
ManagerImpl m = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class SignalDependencies {
|
||||||
public SignalServiceCipher getCipher() {
|
public SignalServiceCipher getCipher() {
|
||||||
return getOrCreate(() -> cipher, () -> {
|
return getOrCreate(() -> cipher, () -> {
|
||||||
final var certificateValidator = new CertificateValidator(serviceEnvironmentConfig.getUnidentifiedSenderTrustRoot());
|
final var certificateValidator = new CertificateValidator(serviceEnvironmentConfig.getUnidentifiedSenderTrustRoot());
|
||||||
final var address = new SignalServiceAddress(credentialsProvider.getUuid(), credentialsProvider.getE164());
|
final var address = new SignalServiceAddress(credentialsProvider.getAci(), credentialsProvider.getE164());
|
||||||
cipher = new SignalServiceCipher(address, dataStore, sessionLock, certificateValidator);
|
cipher = new SignalServiceCipher(address, dataStore, sessionLock, certificateValidator);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ public record MessageEnvelope(
|
||||||
RecipientResolver recipientResolver,
|
RecipientResolver recipientResolver,
|
||||||
RecipientAddressResolver addressResolver
|
RecipientAddressResolver addressResolver
|
||||||
) {
|
) {
|
||||||
return new Mention(addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(mention.getUuid())),
|
return new Mention(addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(mention.getAci())),
|
||||||
mention.getStart(),
|
mention.getStart(),
|
||||||
mention.getLength());
|
mention.getLength());
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStre
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
|
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -410,8 +410,8 @@ public class GroupHelper {
|
||||||
|
|
||||||
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
|
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
|
||||||
for (var member : group.getMembersList()) {
|
for (var member : group.getMembersList()) {
|
||||||
final var uuid = UuidUtil.parseOrThrow(member.getUuid().toByteArray());
|
final var aci = ACI.fromByteString(member.getUuid());
|
||||||
final var recipientId = account.getRecipientStore().resolveRecipient(uuid);
|
final var recipientId = account.getRecipientStore().resolveRecipient(aci);
|
||||||
try {
|
try {
|
||||||
account.getProfileStore()
|
account.getProfileStore()
|
||||||
.storeProfileKey(recipientId, new ProfileKey(member.getProfileKey().toByteArray()));
|
.storeProfileKey(recipientId, new ProfileKey(member.getProfileKey().toByteArray()));
|
||||||
|
|
|
@ -35,9 +35,9 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2AuthorizationString
|
||||||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
|
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
|
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -158,9 +158,9 @@ public class GroupV2Helper {
|
||||||
|
|
||||||
if (!areMembersValid(members)) return null;
|
if (!areMembersValid(members)) return null;
|
||||||
|
|
||||||
var self = new GroupCandidate(getSelfUuid(), Optional.fromNullable(profileKeyCredential));
|
var self = new GroupCandidate(getSelfAci().uuid(), Optional.fromNullable(profileKeyCredential));
|
||||||
var candidates = members.stream()
|
var candidates = members.stream()
|
||||||
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getUuid(),
|
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getAci().uuid(),
|
||||||
Optional.fromNullable(profileKeyCredentialProvider.getProfileKeyCredential(member))))
|
Optional.fromNullable(profileKeyCredentialProvider.getProfileKeyCredential(member))))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
@ -208,8 +208,7 @@ public class GroupV2Helper {
|
||||||
change.setModifyAvatar(GroupChange.Actions.ModifyAvatarAction.newBuilder().setAvatar(avatarCdnKey));
|
change.setModifyAvatar(GroupChange.Actions.ModifyAvatarAction.newBuilder().setAvatar(avatarCdnKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
final var uuid = getSelfUuid();
|
change.setSourceUuid(getSelfAci().toByteString());
|
||||||
change.setSourceUuid(UuidUtil.toByteString(uuid));
|
|
||||||
|
|
||||||
return commitChange(groupInfoV2, change);
|
return commitChange(groupInfoV2, change);
|
||||||
}
|
}
|
||||||
|
@ -224,14 +223,14 @@ public class GroupV2Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
var candidates = newMembers.stream()
|
var candidates = newMembers.stream()
|
||||||
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getUuid(),
|
.map(member -> new GroupCandidate(addressResolver.resolveSignalServiceAddress(member).getAci().uuid(),
|
||||||
Optional.fromNullable(profileKeyCredentialProvider.getProfileKeyCredential(member))))
|
Optional.fromNullable(profileKeyCredentialProvider.getProfileKeyCredential(member))))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
final var uuid = getSelfUuid();
|
final var aci = getSelfAci();
|
||||||
final var change = groupOperations.createModifyGroupMembershipChange(candidates, uuid);
|
final var change = groupOperations.createModifyGroupMembershipChange(candidates, aci.uuid());
|
||||||
|
|
||||||
change.setSourceUuid(UuidUtil.toByteString(uuid));
|
change.setSourceUuid(getSelfAci().toByteString());
|
||||||
|
|
||||||
return commitChange(groupInfoV2, change);
|
return commitChange(groupInfoV2, change);
|
||||||
}
|
}
|
||||||
|
@ -240,8 +239,8 @@ public class GroupV2Helper {
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> membersToMakeAdmin
|
GroupInfoV2 groupInfoV2, Set<RecipientId> membersToMakeAdmin
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var pendingMembersList = groupInfoV2.getGroup().getPendingMembersList();
|
var pendingMembersList = groupInfoV2.getGroup().getPendingMembersList();
|
||||||
final var selfUuid = getSelfUuid();
|
final var selfAci = getSelfAci();
|
||||||
var selfPendingMember = DecryptedGroupUtil.findPendingByUuid(pendingMembersList, selfUuid);
|
var selfPendingMember = DecryptedGroupUtil.findPendingByUuid(pendingMembersList, selfAci.uuid());
|
||||||
|
|
||||||
if (selfPendingMember.isPresent()) {
|
if (selfPendingMember.isPresent()) {
|
||||||
return revokeInvites(groupInfoV2, Set.of(selfPendingMember.get()));
|
return revokeInvites(groupInfoV2, Set.of(selfPendingMember.get()));
|
||||||
|
@ -249,10 +248,12 @@ public class GroupV2Helper {
|
||||||
|
|
||||||
final var adminUuids = membersToMakeAdmin.stream()
|
final var adminUuids = membersToMakeAdmin.stream()
|
||||||
.map(addressResolver::resolveSignalServiceAddress)
|
.map(addressResolver::resolveSignalServiceAddress)
|
||||||
.map(SignalServiceAddress::getUuid)
|
.map(SignalServiceAddress::getAci)
|
||||||
|
.map(ACI::uuid)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
return commitChange(groupInfoV2, groupOperations.createLeaveAndPromoteMembersToAdmin(selfUuid, adminUuids));
|
return commitChange(groupInfoV2,
|
||||||
|
groupOperations.createLeaveAndPromoteMembersToAdmin(selfAci.uuid(), adminUuids));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<DecryptedGroup, GroupChange> removeMembers(
|
public Pair<DecryptedGroup, GroupChange> removeMembers(
|
||||||
|
@ -260,7 +261,8 @@ public class GroupV2Helper {
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var memberUuids = members.stream()
|
final var memberUuids = members.stream()
|
||||||
.map(addressResolver::resolveSignalServiceAddress)
|
.map(addressResolver::resolveSignalServiceAddress)
|
||||||
.map(SignalServiceAddress::getUuid)
|
.map(SignalServiceAddress::getAci)
|
||||||
|
.map(ACI::uuid)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
return ejectMembers(groupInfoV2, memberUuids);
|
return ejectMembers(groupInfoV2, memberUuids);
|
||||||
}
|
}
|
||||||
|
@ -271,7 +273,8 @@ public class GroupV2Helper {
|
||||||
var pendingMembersList = groupInfoV2.getGroup().getPendingMembersList();
|
var pendingMembersList = groupInfoV2.getGroup().getPendingMembersList();
|
||||||
final var memberUuids = members.stream()
|
final var memberUuids = members.stream()
|
||||||
.map(addressResolver::resolveSignalServiceAddress)
|
.map(addressResolver::resolveSignalServiceAddress)
|
||||||
.map(SignalServiceAddress::getUuid)
|
.map(SignalServiceAddress::getAci)
|
||||||
|
.map(ACI::uuid)
|
||||||
.map(uuid -> DecryptedGroupUtil.findPendingByUuid(pendingMembersList, uuid))
|
.map(uuid -> DecryptedGroupUtil.findPendingByUuid(pendingMembersList, uuid))
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
|
@ -341,8 +344,7 @@ public class GroupV2Helper {
|
||||||
? groupOperations.createGroupJoinRequest(profileKeyCredential)
|
? groupOperations.createGroupJoinRequest(profileKeyCredential)
|
||||||
: groupOperations.createGroupJoinDirect(profileKeyCredential);
|
: groupOperations.createGroupJoinDirect(profileKeyCredential);
|
||||||
|
|
||||||
change.setSourceUuid(UuidUtil.toByteString(addressResolver.resolveSignalServiceAddress(selfRecipientId)
|
change.setSourceUuid(addressResolver.resolveSignalServiceAddress(selfRecipientId).getAci().toByteString());
|
||||||
.getUuid()));
|
|
||||||
|
|
||||||
return commitChange(groupSecretParams, decryptedGroupJoinInfo.getRevision(), change, groupLinkPassword);
|
return commitChange(groupSecretParams, decryptedGroupJoinInfo.getRevision(), change, groupLinkPassword);
|
||||||
}
|
}
|
||||||
|
@ -358,8 +360,8 @@ public class GroupV2Helper {
|
||||||
|
|
||||||
final var change = groupOperations.createAcceptInviteChange(profileKeyCredential);
|
final var change = groupOperations.createAcceptInviteChange(profileKeyCredential);
|
||||||
|
|
||||||
final var uuid = addressResolver.resolveSignalServiceAddress(selfRecipientId).getUuid();
|
final var aci = addressResolver.resolveSignalServiceAddress(selfRecipientId).getAci();
|
||||||
change.setSourceUuid(UuidUtil.toByteString(uuid));
|
change.setSourceUuid(aci.toByteString());
|
||||||
|
|
||||||
return commitChange(groupInfoV2, change);
|
return commitChange(groupInfoV2, change);
|
||||||
}
|
}
|
||||||
|
@ -370,7 +372,7 @@ public class GroupV2Helper {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
final var address = addressResolver.resolveSignalServiceAddress(recipientId);
|
final var address = addressResolver.resolveSignalServiceAddress(recipientId);
|
||||||
final var newRole = admin ? Member.Role.ADMINISTRATOR : Member.Role.DEFAULT;
|
final var newRole = admin ? Member.Role.ADMINISTRATOR : Member.Role.DEFAULT;
|
||||||
final var change = groupOperations.createChangeMemberRole(address.getUuid(), newRole);
|
final var change = groupOperations.createChangeMemberRole(address.getAci().uuid(), newRole);
|
||||||
return commitChange(groupInfoV2, change);
|
return commitChange(groupInfoV2, change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +445,7 @@ public class GroupV2Helper {
|
||||||
final DecryptedGroup decryptedGroupState;
|
final DecryptedGroup decryptedGroupState;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
decryptedChange = groupOperations.decryptChange(changeActions, getSelfUuid());
|
decryptedChange = groupOperations.decryptChange(changeActions, getSelfAci().uuid());
|
||||||
decryptedGroupState = DecryptedGroupUtil.apply(previousGroupState, decryptedChange);
|
decryptedGroupState = DecryptedGroupUtil.apply(previousGroupState, decryptedChange);
|
||||||
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
|
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
@ -510,15 +512,15 @@ public class GroupV2Helper {
|
||||||
final var credentials = groupsV2Api.getCredentials(today);
|
final var credentials = groupsV2Api.getCredentials(today);
|
||||||
// TODO cache credentials until they expire
|
// TODO cache credentials until they expire
|
||||||
var authCredentialResponse = credentials.get(today);
|
var authCredentialResponse = credentials.get(today);
|
||||||
final var uuid = getSelfUuid();
|
final var aci = getSelfAci();
|
||||||
try {
|
try {
|
||||||
return groupsV2Api.getGroupsV2AuthorizationString(uuid, today, groupSecretParams, authCredentialResponse);
|
return groupsV2Api.getGroupsV2AuthorizationString(aci, today, groupSecretParams, authCredentialResponse);
|
||||||
} catch (VerificationFailedException e) {
|
} catch (VerificationFailedException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID getSelfUuid() {
|
private ACI getSelfAci() {
|
||||||
return addressResolver.resolveSignalServiceAddress(this.selfRecipientIdProvider.getSelfRecipientId()).getUuid();
|
return addressResolver.resolveSignalServiceAddress(this.selfRecipientIdProvider.getSelfRecipientId()).getAci();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ public final class ProfileHelper {
|
||||||
? avatarStore.retrieveProfileAvatar(account.getSelfAddress())
|
? avatarStore.retrieveProfileAvatar(account.getSelfAddress())
|
||||||
: avatar.isPresent() ? Utils.createStreamDetailsFromFile(avatar.get()) : null) {
|
: avatar.isPresent() ? Utils.createStreamDetailsFromFile(avatar.get()) : null) {
|
||||||
final var avatarPath = dependencies.getAccountManager()
|
final var avatarPath = dependencies.getAccountManager()
|
||||||
.setVersionedProfile(account.getUuid(),
|
.setVersionedProfile(account.getAci(),
|
||||||
account.getProfileKey(),
|
account.getProfileKey(),
|
||||||
newProfile.getInternalServiceName(),
|
newProfile.getInternalServiceName(),
|
||||||
newProfile.getAbout() == null ? "" : newProfile.getAbout(),
|
newProfile.getAbout() == null ? "" : newProfile.getAbout(),
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||||
import org.whispersystems.libsignal.util.Medium;
|
import org.whispersystems.libsignal.util.Medium;
|
||||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||||
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
import org.whispersystems.signalservice.api.kbs.MasterKey;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.storage.StorageKey;
|
import org.whispersystems.signalservice.api.storage.StorageKey;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
@ -77,7 +78,7 @@ public class SignalAccount implements Closeable {
|
||||||
private final FileLock lock;
|
private final FileLock lock;
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
private UUID uuid;
|
private ACI aci;
|
||||||
private String encryptedDeviceName;
|
private String encryptedDeviceName;
|
||||||
private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||||
private boolean isMultiDevice = false;
|
private boolean isMultiDevice = false;
|
||||||
|
@ -205,7 +206,7 @@ public class SignalAccount implements Closeable {
|
||||||
public static SignalAccount createOrUpdateLinkedAccount(
|
public static SignalAccount createOrUpdateLinkedAccount(
|
||||||
File dataPath,
|
File dataPath,
|
||||||
String username,
|
String username,
|
||||||
UUID uuid,
|
ACI aci,
|
||||||
String password,
|
String password,
|
||||||
String encryptedDeviceName,
|
String encryptedDeviceName,
|
||||||
int deviceId,
|
int deviceId,
|
||||||
|
@ -219,7 +220,7 @@ public class SignalAccount implements Closeable {
|
||||||
if (!fileName.exists()) {
|
if (!fileName.exists()) {
|
||||||
return createLinkedAccount(dataPath,
|
return createLinkedAccount(dataPath,
|
||||||
username,
|
username,
|
||||||
uuid,
|
aci,
|
||||||
password,
|
password,
|
||||||
encryptedDeviceName,
|
encryptedDeviceName,
|
||||||
deviceId,
|
deviceId,
|
||||||
|
@ -230,7 +231,7 @@ public class SignalAccount implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
final var account = load(dataPath, username, true, trustNewIdentity);
|
final var account = load(dataPath, username, true, trustNewIdentity);
|
||||||
account.setProvisioningData(username, uuid, password, encryptedDeviceName, deviceId, profileKey);
|
account.setProvisioningData(username, aci, password, encryptedDeviceName, deviceId, profileKey);
|
||||||
account.recipientStore.resolveRecipientTrusted(account.getSelfAddress());
|
account.recipientStore.resolveRecipientTrusted(account.getSelfAddress());
|
||||||
account.sessionStore.archiveAllSessions();
|
account.sessionStore.archiveAllSessions();
|
||||||
account.senderKeyStore.deleteAll();
|
account.senderKeyStore.deleteAll();
|
||||||
|
@ -249,7 +250,7 @@ public class SignalAccount implements Closeable {
|
||||||
private static SignalAccount createLinkedAccount(
|
private static SignalAccount createLinkedAccount(
|
||||||
File dataPath,
|
File dataPath,
|
||||||
String username,
|
String username,
|
||||||
UUID uuid,
|
ACI aci,
|
||||||
String password,
|
String password,
|
||||||
String encryptedDeviceName,
|
String encryptedDeviceName,
|
||||||
int deviceId,
|
int deviceId,
|
||||||
|
@ -264,7 +265,7 @@ public class SignalAccount implements Closeable {
|
||||||
final var pair = openFileChannel(fileName, true);
|
final var pair = openFileChannel(fileName, true);
|
||||||
var account = new SignalAccount(pair.first(), pair.second());
|
var account = new SignalAccount(pair.first(), pair.second());
|
||||||
|
|
||||||
account.setProvisioningData(username, uuid, password, encryptedDeviceName, deviceId, profileKey);
|
account.setProvisioningData(username, aci, password, encryptedDeviceName, deviceId, profileKey);
|
||||||
|
|
||||||
account.initStores(dataPath, identityKey, registrationId, trustNewIdentity);
|
account.initStores(dataPath, identityKey, registrationId, trustNewIdentity);
|
||||||
account.groupStore = new GroupStore(getGroupCachePath(dataPath, username),
|
account.groupStore = new GroupStore(getGroupCachePath(dataPath, username),
|
||||||
|
@ -282,14 +283,14 @@ public class SignalAccount implements Closeable {
|
||||||
|
|
||||||
private void setProvisioningData(
|
private void setProvisioningData(
|
||||||
final String username,
|
final String username,
|
||||||
final UUID uuid,
|
final ACI aci,
|
||||||
final String password,
|
final String password,
|
||||||
final String encryptedDeviceName,
|
final String encryptedDeviceName,
|
||||||
final int deviceId,
|
final int deviceId,
|
||||||
final ProfileKey profileKey
|
final ProfileKey profileKey
|
||||||
) {
|
) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.uuid = uuid;
|
this.aci = aci;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.profileKey = profileKey;
|
this.profileKey = profileKey;
|
||||||
this.encryptedDeviceName = encryptedDeviceName;
|
this.encryptedDeviceName = encryptedDeviceName;
|
||||||
|
@ -404,7 +405,7 @@ public class SignalAccount implements Closeable {
|
||||||
registered = Utils.getNotNullNode(rootNode, "registered").asBoolean();
|
registered = Utils.getNotNullNode(rootNode, "registered").asBoolean();
|
||||||
if (rootNode.hasNonNull("uuid")) {
|
if (rootNode.hasNonNull("uuid")) {
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(rootNode.get("uuid").asText());
|
aci = ACI.from(UUID.fromString(rootNode.get("uuid").asText()));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IOException("Config file contains an invalid uuid, needs to be a valid UUID", e);
|
throw new IOException("Config file contains an invalid uuid, needs to be a valid UUID", e);
|
||||||
}
|
}
|
||||||
|
@ -702,7 +703,7 @@ public class SignalAccount implements Closeable {
|
||||||
var rootNode = jsonProcessor.createObjectNode();
|
var rootNode = jsonProcessor.createObjectNode();
|
||||||
rootNode.put("version", CURRENT_STORAGE_VERSION)
|
rootNode.put("version", CURRENT_STORAGE_VERSION)
|
||||||
.put("username", username)
|
.put("username", username)
|
||||||
.put("uuid", uuid == null ? null : uuid.toString())
|
.put("uuid", aci == null ? null : aci.toString())
|
||||||
.put("deviceName", encryptedDeviceName)
|
.put("deviceName", encryptedDeviceName)
|
||||||
.put("deviceId", deviceId)
|
.put("deviceId", deviceId)
|
||||||
.put("isMultiDevice", isMultiDevice)
|
.put("isMultiDevice", isMultiDevice)
|
||||||
|
@ -830,21 +831,21 @@ public class SignalAccount implements Closeable {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public ACI getAci() {
|
||||||
return uuid;
|
return aci;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUuid(final UUID uuid) {
|
public void setAci(final ACI aci) {
|
||||||
this.uuid = uuid;
|
this.aci = aci;
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress getSelfAddress() {
|
public SignalServiceAddress getSelfAddress() {
|
||||||
return new SignalServiceAddress(uuid, username);
|
return new SignalServiceAddress(aci, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId getSelfRecipientId() {
|
public RecipientId getSelfRecipientId() {
|
||||||
return recipientStore.resolveRecipientTrusted(new RecipientAddress(uuid, username));
|
return recipientStore.resolveRecipientTrusted(new RecipientAddress(aci.uuid(), username));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncryptedDeviceName() {
|
public String getEncryptedDeviceName() {
|
||||||
|
@ -991,7 +992,7 @@ public class SignalAccount implements Closeable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishRegistration(final UUID uuid, final MasterKey masterKey, final String pin) {
|
public void finishRegistration(final ACI aci, final MasterKey masterKey, final String pin) {
|
||||||
this.pinMasterKey = masterKey;
|
this.pinMasterKey = masterKey;
|
||||||
this.storageManifestVersion = -1;
|
this.storageManifestVersion = -1;
|
||||||
this.storageKey = null;
|
this.storageKey = null;
|
||||||
|
@ -999,7 +1000,7 @@ public class SignalAccount implements Closeable {
|
||||||
this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
this.deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||||
this.isMultiDevice = false;
|
this.isMultiDevice = false;
|
||||||
this.registered = true;
|
this.registered = true;
|
||||||
this.uuid = uuid;
|
this.aci = aci;
|
||||||
this.registrationLockPin = pin;
|
this.registrationLockPin = pin;
|
||||||
this.lastReceiveTimestamp = 0;
|
this.lastReceiveTimestamp = 0;
|
||||||
save();
|
save();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.signal.storageservice.protos.groups.Member;
|
||||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||||
import org.signal.storageservice.protos.groups.local.EnabledState;
|
import org.signal.storageservice.protos.groups.local.EnabledState;
|
||||||
import org.signal.zkgroup.groups.GroupMasterKey;
|
import org.signal.zkgroup.groups.GroupMasterKey;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -99,7 +99,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
||||||
}
|
}
|
||||||
return group.getMembersList()
|
return group.getMembersList()
|
||||||
.stream()
|
.stream()
|
||||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||||
.map(recipientResolver::resolveRecipient)
|
.map(recipientResolver::resolveRecipient)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
||||||
}
|
}
|
||||||
return group.getPendingMembersList()
|
return group.getPendingMembersList()
|
||||||
.stream()
|
.stream()
|
||||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||||
.map(recipientResolver::resolveRecipient)
|
.map(recipientResolver::resolveRecipient)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
||||||
}
|
}
|
||||||
return group.getRequestingMembersList()
|
return group.getRequestingMembersList()
|
||||||
.stream()
|
.stream()
|
||||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||||
.map(recipientResolver::resolveRecipient)
|
.map(recipientResolver::resolveRecipient)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
||||||
return group.getMembersList()
|
return group.getMembersList()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(m -> m.getRole() == Member.Role.ADMINISTRATOR)
|
.filter(m -> m.getRole() == Member.Role.ADMINISTRATOR)
|
||||||
.map(m -> UuidUtil.parseOrThrow(m.getUuid().toByteArray()))
|
.map(m -> ACI.fromByteString(m.getUuid()))
|
||||||
.map(recipientResolver::resolveRecipient)
|
.map(recipientResolver::resolveRecipient)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.asamk.signal.manager.storage.recipients;
|
package org.asamk.signal.manager.storage.recipients;
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -7,7 +8,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class RecipientAddress {
|
public class RecipientAddress {
|
||||||
|
|
||||||
public static final UUID UNKNOWN_UUID = new UUID(0, 0);
|
public static final UUID UNKNOWN_UUID = ACI.UNKNOWN.uuid();
|
||||||
|
|
||||||
private final Optional<UUID> uuid;
|
private final Optional<UUID> uuid;
|
||||||
private final Optional<String> e164;
|
private final Optional<String> e164;
|
||||||
|
@ -33,7 +34,7 @@ public class RecipientAddress {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientAddress(SignalServiceAddress address) {
|
public RecipientAddress(SignalServiceAddress address) {
|
||||||
this(Optional.of(address.getUuid()), Optional.ofNullable(address.getNumber().orNull()));
|
this(Optional.of(address.getAci().uuid()), Optional.ofNullable(address.getNumber().orNull()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientAddress(UUID uuid) {
|
public RecipientAddress(UUID uuid) {
|
||||||
|
@ -75,7 +76,7 @@ public class RecipientAddress {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalServiceAddress toSignalServiceAddress() {
|
public SignalServiceAddress toSignalServiceAddress() {
|
||||||
return new SignalServiceAddress(uuid.orElse(UNKNOWN_UUID),
|
return new SignalServiceAddress(ACI.from(uuid.orElse(UNKNOWN_UUID)),
|
||||||
org.whispersystems.libsignal.util.guava.Optional.fromNullable(e164.orElse(null)));
|
org.whispersystems.libsignal.util.guava.Optional.fromNullable(e164.orElse(null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package org.asamk.signal.manager.storage.recipients;
|
package org.asamk.signal.manager.storage.recipients;
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface RecipientResolver {
|
public interface RecipientResolver {
|
||||||
|
|
||||||
RecipientId resolveRecipient(String identifier);
|
RecipientId resolveRecipient(String identifier);
|
||||||
|
@ -12,5 +11,5 @@ public interface RecipientResolver {
|
||||||
|
|
||||||
RecipientId resolveRecipient(SignalServiceAddress address);
|
RecipientId resolveRecipient(SignalServiceAddress address);
|
||||||
|
|
||||||
RecipientId resolveRecipient(UUID uuid);
|
RecipientId resolveRecipient(ACI aci);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.signal.zkgroup.profiles.ProfileKey;
|
||||||
import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
@ -137,8 +138,8 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipientId resolveRecipient(UUID uuid) {
|
public RecipientId resolveRecipient(ACI aci) {
|
||||||
return resolveRecipient(new RecipientAddress(uuid), false);
|
return resolveRecipient(new RecipientAddress(aci.uuid()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,19 +148,19 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId resolveRecipient(
|
public RecipientId resolveRecipient(
|
||||||
final String number, Supplier<UUID> uuidSupplier
|
final String number, Supplier<ACI> aciSupplier
|
||||||
) throws UnregisteredUserException {
|
) throws UnregisteredUserException {
|
||||||
final Optional<Recipient> byNumber;
|
final Optional<Recipient> byNumber;
|
||||||
synchronized (recipients) {
|
synchronized (recipients) {
|
||||||
byNumber = findByNumberLocked(number);
|
byNumber = findByNumberLocked(number);
|
||||||
}
|
}
|
||||||
if (byNumber.isEmpty() || byNumber.get().getAddress().getUuid().isEmpty()) {
|
if (byNumber.isEmpty() || byNumber.get().getAddress().getUuid().isEmpty()) {
|
||||||
final var uuid = uuidSupplier.get();
|
final var aci = aciSupplier.get();
|
||||||
if (uuid == null) {
|
if (aci == null) {
|
||||||
throw new UnregisteredUserException(number, null);
|
throw new UnregisteredUserException(number, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolveRecipient(new RecipientAddress(uuid, number), false);
|
return resolveRecipient(new RecipientAddress(aci.uuid(), number), false);
|
||||||
}
|
}
|
||||||
return byNumber.get().getRecipientId();
|
return byNumber.get().getRecipientId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.asamk.signal.manager.util;
|
||||||
|
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
@ -11,7 +11,6 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MessageCacheUtils {
|
public class MessageCacheUtils {
|
||||||
|
|
||||||
|
@ -24,9 +23,9 @@ public class MessageCacheUtils {
|
||||||
}
|
}
|
||||||
var type = in.readInt();
|
var type = in.readInt();
|
||||||
var source = in.readUTF();
|
var source = in.readUTF();
|
||||||
UUID sourceUuid = null;
|
ACI sourceAci = null;
|
||||||
if (version >= 3) {
|
if (version >= 3) {
|
||||||
sourceUuid = UuidUtil.parseOrNull(in.readUTF());
|
sourceAci = ACI.parseOrNull(in.readUTF());
|
||||||
}
|
}
|
||||||
var sourceDevice = in.readInt();
|
var sourceDevice = in.readInt();
|
||||||
if (version == 1) {
|
if (version == 1) {
|
||||||
|
@ -59,9 +58,9 @@ public class MessageCacheUtils {
|
||||||
if (version >= 4) {
|
if (version >= 4) {
|
||||||
serverDeliveredTimestamp = in.readLong();
|
serverDeliveredTimestamp = in.readLong();
|
||||||
}
|
}
|
||||||
Optional<SignalServiceAddress> addressOptional = sourceUuid == null
|
Optional<SignalServiceAddress> addressOptional = sourceAci == null
|
||||||
? Optional.absent()
|
? Optional.absent()
|
||||||
: Optional.of(new SignalServiceAddress(sourceUuid, source));
|
: Optional.of(new SignalServiceAddress(sourceAci, source));
|
||||||
return new SignalServiceEnvelope(type,
|
return new SignalServiceEnvelope(type,
|
||||||
addressOptional,
|
addressOptional,
|
||||||
sourceDevice,
|
sourceDevice,
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.whispersystems.libsignal.fingerprint.Fingerprint;
|
||||||
import org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator;
|
import org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -51,8 +50,8 @@ public class Utils {
|
||||||
if (isUuidCapable) {
|
if (isUuidCapable) {
|
||||||
// Version 2: UUID user
|
// Version 2: UUID user
|
||||||
version = 2;
|
version = 2;
|
||||||
ownId = UuidUtil.toByteArray(ownAddress.getUuid());
|
ownId = ownAddress.getAci().toByteArray();
|
||||||
theirId = UuidUtil.toByteArray(theirAddress.getUuid());
|
theirId = theirAddress.getAci().toByteArray();
|
||||||
} else {
|
} else {
|
||||||
// Version 1: E164 user
|
// Version 1: E164 user
|
||||||
version = 1;
|
version = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue