mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update libsignal-service
This commit is contained in:
parent
6ecda07577
commit
ee195c966e
12 changed files with 77 additions and 49 deletions
|
@ -102,7 +102,7 @@ public class AccountHelper {
|
|||
final var whoAmI = dependencies.getAccountManager().getWhoAmI();
|
||||
final var number = whoAmI.getNumber();
|
||||
final var aci = ACI.parseOrThrow(whoAmI.getAci());
|
||||
final var pni = PNI.parseUnPrefixedOrThrow(whoAmI.getPni());
|
||||
final var pni = PNI.parseOrThrow(whoAmI.getPni());
|
||||
if (number.equals(account.getNumber()) && aci.equals(account.getAci()) && pni.equals(account.getPni())) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ public class GroupHelper {
|
|||
|
||||
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
|
||||
for (var member : group.getMembersList()) {
|
||||
final var serviceId = ServiceId.parseOrThrow(member.getUuid());
|
||||
final var serviceId = ServiceId.parseOrThrow(member.getAciBytes());
|
||||
final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
|
||||
final var profileStore = account.getProfileStore();
|
||||
if (profileStore.getProfileKey(recipientId) != null) {
|
||||
|
|
|
@ -124,9 +124,10 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
int findRevisionWeWereAdded(DecryptedGroup partialDecryptedGroup) {
|
||||
ByteString bytes = getSelfAci().toByteString();
|
||||
ByteString aciBytes = getSelfAci().toByteString();
|
||||
ByteString pniBytes = getSelfPni().toByteString();
|
||||
for (DecryptedMember decryptedMember : partialDecryptedGroup.getMembersList()) {
|
||||
if (decryptedMember.getUuid().equals(bytes)) {
|
||||
if (decryptedMember.getAciBytes().equals(aciBytes) || decryptedMember.getPniBytes().equals(pniBytes)) {
|
||||
return decryptedMember.getJoinedAtRevision();
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +215,7 @@ class GroupV2Helper {
|
|||
change.setModifyAvatar(GroupChange.Actions.ModifyAvatarAction.newBuilder().setAvatar(avatarCdnKey));
|
||||
}
|
||||
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
change.setSourceServiceId(getSelfAci().toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -240,7 +241,7 @@ class GroupV2Helper {
|
|||
final var aci = getSelfAci();
|
||||
final var change = groupOperations.createModifyGroupMembershipChange(candidates, bannedUuids, aci);
|
||||
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
change.setSourceServiceId(getSelfAci().toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -262,8 +263,7 @@ class GroupV2Helper {
|
|||
.map(ServiceId::getRawUuid)
|
||||
.toList();
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
return commitChange(groupInfoV2,
|
||||
groupOperations.createLeaveAndPromoteMembersToAdmin(selfAci.getRawUuid(), adminUuids));
|
||||
return commitChange(groupInfoV2, groupOperations.createLeaveAndPromoteMembersToAdmin(selfAci, adminUuids));
|
||||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChange> removeMembers(
|
||||
|
@ -272,7 +272,8 @@ class GroupV2Helper {
|
|||
final var memberUuids = members.stream()
|
||||
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getServiceId)
|
||||
.map(ServiceId::getRawUuid)
|
||||
.filter(m -> m instanceof ACI)
|
||||
.map(m -> (ACI) m)
|
||||
.collect(Collectors.toSet());
|
||||
return ejectMembers(groupInfoV2, memberUuids);
|
||||
}
|
||||
|
@ -294,7 +295,6 @@ class GroupV2Helper {
|
|||
final var memberUuids = members.stream()
|
||||
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getServiceId)
|
||||
.map(ServiceId::getRawUuid)
|
||||
.collect(Collectors.toSet());
|
||||
return refuseJoinRequest(groupInfoV2, memberUuids);
|
||||
}
|
||||
|
@ -318,18 +318,15 @@ class GroupV2Helper {
|
|||
) throws IOException {
|
||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
final var uuids = block.stream()
|
||||
.map(member -> context.getRecipientHelper()
|
||||
.resolveSignalServiceAddress(member)
|
||||
.getServiceId()
|
||||
.getRawUuid())
|
||||
final var serviceIds = block.stream()
|
||||
.map(member -> context.getRecipientHelper().resolveSignalServiceAddress(member).getServiceId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
final var change = groupOperations.createBanUuidsChange(uuids,
|
||||
final var change = groupOperations.createBanServiceIdsChange(serviceIds,
|
||||
false,
|
||||
groupInfoV2.getGroup().getBannedMembersList());
|
||||
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
change.setSourceServiceId(getSelfAci().toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -345,7 +342,7 @@ class GroupV2Helper {
|
|||
|
||||
final var change = groupOperations.createUnbanServiceIdsChange(serviceIds);
|
||||
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
change.setSourceServiceId(getSelfAci().toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -396,8 +393,7 @@ class GroupV2Helper {
|
|||
Pair<DecryptedGroup, GroupChange> updateSelfProfileKey(GroupInfoV2 groupInfoV2) throws IOException {
|
||||
Optional<DecryptedMember> selfInGroup = groupInfoV2.getGroup() == null
|
||||
? Optional.empty()
|
||||
: DecryptedGroupUtil.findMemberByUuid(groupInfoV2.getGroup().getMembersList(),
|
||||
getSelfAci().getRawUuid());
|
||||
: DecryptedGroupUtil.findMemberByAci(groupInfoV2.getGroup().getMembersList(), getSelfAci());
|
||||
if (selfInGroup.isEmpty()) {
|
||||
logger.trace("Not updating group, self not in group " + groupInfoV2.getGroupId().toBase64());
|
||||
return null;
|
||||
|
@ -420,7 +416,7 @@ class GroupV2Helper {
|
|||
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
final var change = groupOperations.createUpdateProfileKeyCredentialChange(profileKeyCredential);
|
||||
change.setSourceUuid(getSelfAci().toByteString());
|
||||
change.setSourceServiceId(getSelfAci().toByteString());
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
||||
|
@ -443,7 +439,7 @@ class GroupV2Helper {
|
|||
? groupOperations.createGroupJoinRequest(profileKeyCredential)
|
||||
: groupOperations.createGroupJoinDirect(profileKeyCredential);
|
||||
|
||||
change.setSourceUuid(context.getRecipientHelper()
|
||||
change.setSourceServiceId(context.getRecipientHelper()
|
||||
.resolveSignalServiceAddress(selfRecipientId)
|
||||
.getServiceId()
|
||||
.toByteString());
|
||||
|
@ -463,7 +459,7 @@ class GroupV2Helper {
|
|||
final var change = groupOperations.createAcceptInviteChange(profileKeyCredential);
|
||||
|
||||
final var aci = context.getRecipientHelper().resolveSignalServiceAddress(selfRecipientId).getServiceId();
|
||||
change.setSourceUuid(aci.toByteString());
|
||||
change.setSourceServiceId(aci.toByteString());
|
||||
|
||||
return commitChange(groupInfoV2, change);
|
||||
}
|
||||
|
@ -524,7 +520,7 @@ class GroupV2Helper {
|
|||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
final var uuidCipherTexts = pendingMembers.stream().map(member -> {
|
||||
try {
|
||||
return new UuidCiphertext(member.getUuidCipherText().toByteArray());
|
||||
return new UuidCiphertext(member.getServiceIdCipherText().toByteArray());
|
||||
} catch (InvalidInputException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
@ -540,17 +536,17 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
private Pair<DecryptedGroup, GroupChange> refuseJoinRequest(
|
||||
GroupInfoV2 groupInfoV2, Set<UUID> uuids
|
||||
GroupInfoV2 groupInfoV2, Set<ServiceId> serviceIds
|
||||
) throws IOException {
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
return commitChange(groupInfoV2, groupOperations.createRefuseGroupJoinRequest(uuids, false, List.of()));
|
||||
return commitChange(groupInfoV2, groupOperations.createRefuseGroupJoinRequest(serviceIds, false, List.of()));
|
||||
}
|
||||
|
||||
private Pair<DecryptedGroup, GroupChange> ejectMembers(
|
||||
GroupInfoV2 groupInfoV2, Set<UUID> uuids
|
||||
GroupInfoV2 groupInfoV2, Set<ACI> members
|
||||
) throws IOException {
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
return commitChange(groupInfoV2, groupOperations.createRemoveMembersChange(uuids, false, List.of()));
|
||||
return commitChange(groupInfoV2, groupOperations.createRemoveMembersChange(members, false, List.of()));
|
||||
}
|
||||
|
||||
private Pair<DecryptedGroup, GroupChange> commitChange(
|
||||
|
@ -593,16 +589,16 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<ServiceId, ProfileKey> getAuthoritativeProfileKeyFromChange(final DecryptedGroupChange change) {
|
||||
UUID editor = UuidUtil.fromByteStringOrNull(change.getEditor());
|
||||
UUID editor = UuidUtil.fromByteStringOrNull(change.getEditorServiceIdBytes());
|
||||
final var editorProfileKeyBytes = Stream.concat(Stream.of(change.getNewMembersList().stream(),
|
||||
change.getPromotePendingMembersList().stream(),
|
||||
change.getModifiedProfileKeysList().stream())
|
||||
.flatMap(Function.identity())
|
||||
.filter(m -> UuidUtil.fromByteString(m.getUuid()).equals(editor))
|
||||
.filter(m -> UuidUtil.fromByteString(m.getAciBytes()).equals(editor))
|
||||
.map(DecryptedMember::getProfileKey),
|
||||
change.getNewRequestingMembersList()
|
||||
.stream()
|
||||
.filter(m -> UuidUtil.fromByteString(m.getUuid()).equals(editor))
|
||||
.filter(m -> UuidUtil.fromByteString(m.getAciBytes()).equals(editor))
|
||||
.map(DecryptedRequestingMember::getProfileKey)).findFirst();
|
||||
|
||||
if (editorProfileKeyBytes.isEmpty()) {
|
||||
|
|
|
@ -101,14 +101,14 @@ public class StorageHelper {
|
|||
}
|
||||
|
||||
final var contactRecord = record.getContact().get();
|
||||
final var aci = contactRecord.getAci();
|
||||
final var aci = contactRecord.getAci().orElse(null);
|
||||
final var pni = contactRecord.getPni().orElse(null);
|
||||
if (contactRecord.getNumber().isEmpty() && aci.isUnknown()) {
|
||||
if (contactRecord.getNumber().isEmpty() && aci == null && pni == null) {
|
||||
return;
|
||||
}
|
||||
final var address = new RecipientAddress(aci, pni, contactRecord.getNumber().orElse(null));
|
||||
var recipientId = account.getRecipientResolver().resolveRecipient(address);
|
||||
if (aci.isValid() && contactRecord.getUsername().isPresent()) {
|
||||
if (aci != null && contactRecord.getUsername().isPresent()) {
|
||||
recipientId = account.getRecipientTrustedResolver()
|
||||
.resolveRecipientTrusted(aci, contactRecord.getUsername().get());
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class StorageHelper {
|
|||
logger.warn("Received invalid contact profile key from storage");
|
||||
}
|
||||
}
|
||||
if (contactRecord.getIdentityKey().isPresent() && aci.isValid()) {
|
||||
if (contactRecord.getIdentityKey().isPresent() && aci != null) {
|
||||
try {
|
||||
logger.trace("Storing identity key {}", recipientId);
|
||||
final var identityKey = new IdentityKey(contactRecord.getIdentityKey().get());
|
||||
|
|
|
@ -165,7 +165,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
||||
final var aci = ACI.parseOrThrow(response.getUuid());
|
||||
final var pni = PNI.parseUnPrefixedOrThrow(response.getPni());
|
||||
final var pni = PNI.parseOrThrow(response.getPni());
|
||||
account.finishRegistration(aci, pni, masterKey, pin, aciPreKeys, pniPreKeys);
|
||||
accountFileUpdater.updateAccountIdentifiers(account.getNumber(), aci);
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
if (rootNode.hasNonNull("pni")) {
|
||||
try {
|
||||
pni = PNI.parseUnPrefixedOrThrow(rootNode.get("pni").asText());
|
||||
pni = PNI.parseOrThrow(rootNode.get("pni").asText());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IOException("Config file contains an invalid pni, needs to be a valid UUID", e);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.manager.storage.groups;
|
|||
import org.asamk.signal.manager.api.GroupIdV2;
|
||||
import org.asamk.signal.manager.api.GroupInviteLinkUrl;
|
||||
import org.asamk.signal.manager.api.GroupPermission;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientResolver;
|
||||
import org.signal.libsignal.zkgroup.groups.GroupMasterKey;
|
||||
|
@ -114,7 +115,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getMembersList()
|
||||
.stream()
|
||||
.map(m -> ServiceId.parseOrThrow(m.getUuid()))
|
||||
.map(m -> ServiceId.parseOrThrow(m.getAciBytes()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getBannedMembersList()
|
||||
.stream()
|
||||
.map(m -> ServiceId.parseOrThrow(m.getServiceIdBinary()))
|
||||
.map(m -> ServiceId.parseOrThrow(m.getServiceIdBytes()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -138,7 +139,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getPendingMembersList()
|
||||
.stream()
|
||||
.map(m -> ServiceId.parseOrThrow(m.getServiceIdBinary()))
|
||||
.map(m -> ServiceId.parseOrThrow(m.getServiceIdBytes()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
}
|
||||
return group.getRequestingMembersList()
|
||||
.stream()
|
||||
.map(m -> ServiceId.parseOrThrow(m.getUuid()))
|
||||
.map(m -> ServiceId.parseOrThrow(m.getAciBytes()))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -163,7 +164,9 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
return group.getMembersList()
|
||||
.stream()
|
||||
.filter(m -> m.getRole() == Member.Role.ADMINISTRATOR)
|
||||
.map(m -> ServiceId.parseOrThrow(m.getUuid()))
|
||||
.map(m -> new RecipientAddress(ServiceId.ACI.parseOrNull(m.getAciBytes()),
|
||||
ServiceId.PNI.parseOrNull(m.getPniBytes()),
|
||||
null))
|
||||
.map(recipientResolver::resolveRecipient)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
|
|
@ -208,4 +208,14 @@ public class KyberPreKeyStore implements SignalServiceKyberPreKeyStore {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllStaleOneTimeKyberPreKeys(final long threshold, final int minCount) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markAllOneTimeKyberPreKeysStaleIfNecessary(final long staleTime) {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,4 +242,24 @@ public class SignalProtocolStore implements SignalServiceAccountDataStore {
|
|||
public void storeLastResortKyberPreKey(final int i, final KyberPreKeyRecord kyberPreKeyRecord) {
|
||||
kyberPreKeyStore.storeLastResortKyberPreKey(i, kyberPreKeyRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllStaleOneTimeKyberPreKeys(final long threshold, final int minCount) {
|
||||
kyberPreKeyStore.deleteAllStaleOneTimeKyberPreKeys(threshold, minCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markAllOneTimeKyberPreKeysStaleIfNecessary(final long staleTime) {
|
||||
kyberPreKeyStore.markAllOneTimeKyberPreKeysStaleIfNecessary(staleTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllStaleOneTimeEcPreKeys(final long l, final int i) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markAllOneTimeEcPreKeysStaleIfNecessary(final long l) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ public class AttachmentUtils {
|
|||
blurHash,
|
||||
null,
|
||||
null,
|
||||
resumableUploadSpec,
|
||||
false);
|
||||
resumableUploadSpec);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue