Add GV2 accept by PNI invite.

This commit is contained in:
Cody Henthorne
2022-07-11 15:20:00 -04:00
parent b223ebe95e
commit c4bef8099f
71 changed files with 1468 additions and 1016 deletions

View File

@@ -85,7 +85,6 @@ public final class FeatureFlags {
private static final String GROUP_CALL_RINGING = "android.calling.groupCallRinging";
private static final String DONOR_BADGES = "android.donorBadges.6";
private static final String DONOR_BADGES_DISPLAY = "android.donorBadges.display.4";
private static final String CDSH = "android.cdsh";
private static final String STORIES = "android.stories.2";
private static final String STORIES_TEXT_FUNCTIONS = "android.stories.text.functions";
private static final String HARDWARE_AEC_BLOCKLIST_MODELS = "android.calling.hardwareAecBlockList";
@@ -134,7 +133,6 @@ public final class FeatureFlags {
SUGGEST_SMS_BLACKLIST,
MAX_GROUP_CALL_RING_SIZE,
GROUP_CALL_RINGING,
CDSH,
SENDER_KEY_MAX_AGE,
DONOR_BADGES,
DONOR_BADGES_DISPLAY,
@@ -199,7 +197,6 @@ public final class FeatureFlags {
SENDER_KEY,
MAX_GROUP_CALL_RING_SIZE,
GROUP_CALL_RINGING,
CDSH,
SENDER_KEY_MAX_AGE,
DONOR_BADGES_DISPLAY,
DONATE_MEGAPHONE,
@@ -470,10 +467,6 @@ public final class FeatureFlags {
return getBoolean(DONOR_BADGES_DISPLAY, true);
}
public static boolean cdsh() {
return Environment.IS_STAGING && getBoolean(CDSH, false);
}
/** A comma-separated list of models that should *not* use hardware AEC for calling. */
public static @NonNull String hardwareAecBlocklistModels() {
return getString(HARDWARE_AEC_BLOCKLIST_MODELS, "");

View File

@@ -44,6 +44,13 @@ fun Long.toLocalDateTime(zoneId: ZoneId = ZoneId.systemDefault()): LocalDateTime
return LocalDateTime.ofInstant(Instant.ofEpochMilli(this), zoneId)
}
/**
* Convert milliseconds to local date time with provided [zoneId].
*/
fun Instant.toLocalDateTime(zoneId: ZoneId = ZoneId.systemDefault()): LocalDateTime {
return LocalDateTime.ofInstant(this, zoneId)
}
/**
* Converts milliseconds to local time with provided [zoneId].
*/

View File

@@ -12,6 +12,7 @@ import org.signal.libsignal.protocol.IdentityKeyPair;
import org.signal.libsignal.protocol.InvalidKeyException;
import org.signal.libsignal.protocol.util.Pair;
import org.signal.libsignal.zkgroup.InvalidInputException;
import org.signal.libsignal.zkgroup.profiles.ExpiringProfileKeyCredential;
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
import org.thoughtcrime.securesms.badges.models.Badge;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
@@ -282,6 +283,35 @@ public final class ProfileUtil {
Recipient.self().getBadges());
}
/**
* Attempts to update just the expiring profile key credential with a new one. If unable, an empty optional is returned.
*
* Note: It will try to find missing profile key credentials from the server and persist locally.
*/
public static Optional<ExpiringProfileKeyCredential> updateExpiringProfileKeyCredential(@NonNull Recipient recipient) throws IOException {
ProfileKey profileKey = ProfileKeyUtil.profileKeyOrNull(recipient.getProfileKey());
if (profileKey != null) {
Log.i(TAG, String.format("Updating profile key credential on recipient %s, fetching", recipient.getId()));
Optional<ExpiringProfileKeyCredential> profileKeyCredentialOptional = ApplicationDependencies.getSignalServiceAccountManager()
.resolveProfileKeyCredential(recipient.requireServiceId(), profileKey, Locale.getDefault());
if (profileKeyCredentialOptional.isPresent()) {
boolean updatedProfileKey = SignalDatabase.recipients().setProfileKeyCredential(recipient.getId(), profileKey, profileKeyCredentialOptional.get());
if (!updatedProfileKey) {
Log.w(TAG, String.format("Failed to update the profile key credential on recipient %s", recipient.getId()));
} else {
Log.i(TAG, String.format("Got new profile key credential for recipient %s", recipient.getId()));
return profileKeyCredentialOptional;
}
}
}
return Optional.empty();
}
private static void uploadProfile(@NonNull ProfileName profileName,
@Nullable String about,
@Nullable String aboutEmoji,