Refine scaffolding for testing gv2.

This commit is contained in:
Matthew Chen 2020-07-27 16:32:35 -03:00
parent 231bd99567
commit 4db7dd5ca3
6 changed files with 49 additions and 5 deletions

View File

@ -27,6 +27,11 @@
return SSKEnvironment.shared.tsAccountManager;
}
- (OWSProfileManager *)profileManager
{
return [OWSProfileManager sharedManager];
}
#pragma mark -
- (void)dealloc
@ -227,6 +232,10 @@
withString:@""];
[debugSection
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Audio Category: %@", audioCategory]]];
NSData *localProfileKey = [self.profileManager localProfileKey].keyData;
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Local Profile Key: %@",
localProfileKey.hexadecimalString]]];
}
- (void)addGroupsV2memberStatusIndicators:(OWSTableContents *)contents

View File

@ -56,6 +56,16 @@ class TestingViewController: OWSTableViewController {
contents.addSection(section)
}
do {
let section = OWSTableSection()
section.footerTitle = LocalizationNotNeeded("Client will not try to create v2 groups.")
section.add(OWSTableItem.switch(withText: LocalizationNotNeeded("Groups v2: Only create v1 groups"),
isOn: { DebugFlags.groupsV2onlyCreateV1Groups },
target: self,
selector: #selector(didToggleGroupsV2onlyCreateV1Groups)))
contents.addSection(section)
}
self.contents = contents
}
@ -73,4 +83,9 @@ class TestingViewController: OWSTableViewController {
func didToggleGroupsV2corruptInvites(_ sender: UISwitch) {
DebugFlags.groupsV2corruptInvites = sender.isOn
}
@objc
func didToggleGroupsV2onlyCreateV1Groups(_ sender: UISwitch) {
DebugFlags.groupsV2onlyCreateV1Groups = sender.isOn
}
}

View File

@ -149,6 +149,9 @@ class DebugUIGroupsV2: DebugUIPage {
// V2 group members must have a uuid.
allAddresses = allAddresses.filter { $0.uuid != nil }
}
guard allAddresses.count >= 3 else {
return owsFailDebug("Not enough Signal users in your contacts.")
}
let updaterAddress: SignalServiceAddress?
if isAnonymousUpdate {
updaterAddress = nil

View File

@ -255,12 +255,11 @@ extension ConversationSettingsViewController {
// This will not appear in public builds.
if DebugFlags.showProfileKeyAndUuidsIndicator {
let hasProfileKey = self.databaseStorage.uiRead { transaction in
self.profileManager.profileKeyData(for: recipientAddress, transaction: transaction) != nil
let profileKey = self.databaseStorage.uiRead { transaction in
self.profileManager.profileKeyData(for: recipientAddress, transaction: transaction)
}
let subtitle = "Has Profile Key: \(hasProfileKey)"
builder.addSubtitleLabel(attributedText: subtitle.asAttributedString)
let text = String(format: "Profile Key: %@", profileKey?.hexadecimalString ?? "Unknown")
builder.addSubtitleLabel(attributedText: text.asAttributedString)
}
builder.addLastSubviews()

View File

@ -325,6 +325,20 @@ public class DebugFlags: BaseFlags {
}
}
private static let _groupsV2onlyCreateV1Groups = AtomicBool(false)
@objc
public static var groupsV2onlyCreateV1Groups: Bool {
get {
guard build.includes(.qa) else {
return false
}
return _groupsV2onlyCreateV1Groups.get()
}
set {
_groupsV2onlyCreateV1Groups.set(newValue)
}
}
@objc
public static let groupsV2ignoreCorruptInvites = false

View File

@ -152,6 +152,10 @@ public struct TSGroupModelBuilder {
Logger.info("Creating v1 group due to feature flags.")
return .V1
}
if DebugFlags.groupsV2onlyCreateV1Groups {
Logger.info("Creating v1 group due to debug flag.")
return .V1
}
let canUseV2 = GroupManager.canUseV2(for: members, transaction: transaction)
if canUseV2 {
Logger.info("Creating v2 group.")