From f4a152b0feb820dedcd75aa11bb3a3cdd080fac5 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Tue, 2 Jun 2020 11:48:35 -0300 Subject: [PATCH] Fetch own profile after GV2 feature flag is enabled, improve GV2 capability check. --- .../groups/GroupsV2CapabilityChecker.java | 39 ++++++++++++++----- .../securesms/util/FeatureFlags.java | 5 ++- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2CapabilityChecker.java b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2CapabilityChecker.java index c5b69fd424c..04f0eebae4c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2CapabilityChecker.java +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2CapabilityChecker.java @@ -42,25 +42,46 @@ boolean allSupportGroupsV2AndUuid(@NonNull Collection recipientIds) Recipient member = Recipient.resolved(recipientId); Recipient.Capability gv2Capability = member.getGroupsV2Capability(); - if (gv2Capability == Recipient.Capability.UNKNOWN) { + if (gv2Capability != Recipient.Capability.SUPPORTED) { if (!ApplicationDependencies.getJobManager().runSynchronously(RetrieveProfileJob.forRecipient(member), TimeUnit.SECONDS.toMillis(1000)).isPresent()) { throw new IOException("Recipient capability was not retrieved in time"); } } - - if (gv2Capability != Recipient.Capability.SUPPORTED) { - Log.i(TAG, "At least one recipient does not support GV2, capability was " + gv2Capability); - return false; - } } + boolean noSelfGV2Support = false; + int noGv2Count = 0; + int noUuidCount = 0; + for (RecipientId recipientId : recipientIdsSet) { - Recipient member = Recipient.resolved(recipientId); + Recipient member = Recipient.resolved(recipientId); + Recipient.Capability gv2Capability = member.getGroupsV2Capability(); + + if (gv2Capability != Recipient.Capability.SUPPORTED) { + Log.w(TAG, "At least one recipient does not support GV2, capability was " + gv2Capability); + + noGv2Count++; + if (member.isLocalNumber()) { + noSelfGV2Support = true; + } + } if (!member.hasUuid()) { - Log.i(TAG, "At least one recipient did not have a UUID known to us"); - return false; + noUuidCount++; + } + } + + if (noGv2Count + noUuidCount > 0) { + if (noUuidCount > 0) { + Log.w(TAG, noUuidCount + " recipient(s) did not have a UUID known to us"); + } + if (noGv2Count > 0) { + Log.w(TAG, noGv2Count + " recipient(s) do not support GV2"); + if (noSelfGV2Support) { + Log.w(TAG, "Self does not support GV2"); + } } + return false; } return true; diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java b/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java index 9cc3fbcf820..a77a7687526 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java @@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies; import org.thoughtcrime.securesms.jobs.ProfileUploadJob; import org.thoughtcrime.securesms.jobs.RefreshAttributesJob; +import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob; import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob; import org.thoughtcrime.securesms.keyvalue.SignalStore; import org.thoughtcrime.securesms.logging.Log; @@ -138,7 +139,9 @@ public final class FeatureFlags { private static final Map FLAG_CHANGE_LISTENERS = new HashMap() {{ put(MESSAGE_REQUESTS, (change) -> SignalStore.setMessageRequestEnableTime(change == Change.ENABLED ? System.currentTimeMillis() : 0)); put(VERSIONED_PROFILES, (change) -> ApplicationDependencies.getJobManager().add(new ProfileUploadJob())); - put(GROUPS_V2, (change) -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob())); + put(GROUPS_V2, (change) -> ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob()) + .then(new RefreshOwnProfileJob()) + .enqueue()); }}; private static final Map REMOTE_VALUES = new TreeMap<>();