Add support for PniSignatureMessages.

This commit is contained in:
Greyson Parrelli
2022-08-24 18:16:42 -04:00
committed by GitHub
parent 1e499fd12f
commit 61498037f3
29 changed files with 602 additions and 210 deletions

View File

@@ -138,6 +138,7 @@ public class Recipient {
private final boolean hasGroupsInCommon;
private final List<Badge> badges;
private final boolean isReleaseNotesRecipient;
private final boolean needsPniSignature;
/**
* Returns a {@link LiveRecipient}, which contains a {@link Recipient} that may or may not be
@@ -215,20 +216,6 @@ public class Recipient {
return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null));
}
/**
* Returns a fully-populated {@link Recipient} based off of a {@link SignalServiceAddress},
* creating one in the database if necessary. We special-case GV1 members because we want to
* prioritize E164 addresses and not use the UUIDs if possible.
*/
@WorkerThread
public static @NonNull Recipient externalGV1Member(@NonNull SignalServiceAddress address) {
if (address.getNumber().isPresent()) {
return externalPush(null, address.getNumber().get());
} else {
return externalPush(address.getServiceId());
}
}
/**
* Returns a fully-populated {@link Recipient} based off of a ServiceId, creating one
* in the database if necessary.
@@ -452,6 +439,7 @@ public class Recipient {
this.hasGroupsInCommon = false;
this.badges = Collections.emptyList();
this.isReleaseNotesRecipient = false;
this.needsPniSignature = false;
}
public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) {
@@ -510,6 +498,7 @@ public class Recipient {
this.hasGroupsInCommon = details.hasGroupsInCommon;
this.badges = details.badges;
this.isReleaseNotesRecipient = details.isReleaseChannel;
this.needsPniSignature = details.needsPniSignature;
}
public @NonNull RecipientId getId() {
@@ -1221,6 +1210,10 @@ public class Recipient {
return isReleaseNotesRecipient || isSelf;
}
public boolean needsPniSignature() {
return FeatureFlags.phoneNumberPrivacy() && needsPniSignature;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@@ -88,6 +88,7 @@ public class RecipientDetails {
final boolean hasGroupsInCommon;
final List<Badge> badges;
final boolean isReleaseChannel;
final boolean needsPniSignature;
public RecipientDetails(@Nullable String groupName,
@Nullable String systemContactName,
@@ -153,6 +154,7 @@ public class RecipientDetails {
this.hasGroupsInCommon = record.hasGroupsInCommon();
this.badges = record.getBadges();
this.isReleaseChannel = isReleaseChannel;
this.needsPniSignature = record.needsPniSignature();
}
private RecipientDetails() {
@@ -210,6 +212,7 @@ public class RecipientDetails {
this.hasGroupsInCommon = false;
this.badges = Collections.emptyList();
this.isReleaseChannel = false;
this.needsPniSignature = false;
}
public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientRecord settings) {