From 66fd838dca498d1dad3ea4aaa451eff7325b3b56 Mon Sep 17 00:00:00 2001 From: Max Radermacher Date: Wed, 21 May 2025 18:54:39 -0500 Subject: [PATCH] Remove unused code from NewGroupSeed --- .../NewGroupConfirmViewController.swift | 8 ++---- .../NewGroupView/NewGroupState.swift | 2 +- SignalServiceKit/Groups/NewGroupSeed.swift | 28 ------------------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift b/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift index 1b604bd981..e92d57ecdd 100644 --- a/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift +++ b/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift @@ -33,9 +33,8 @@ public class NewGroupConfirmViewController: OWSTableViewController2 { init(newGroupState: NewGroupState) { self.newGroupState = newGroupState - let groupId = newGroupState.groupSeed.groupIdV2 self.helper = GroupAttributesEditorHelper( - groupId: groupId, + groupId: try! newGroupState.groupSeed.groupSecretParams.getPublicParams().getGroupIdentifier().serialize().asData, groupNameOriginal: newGroupState.groupName, groupDescriptionOriginal: nil, avatarOriginalData: newGroupState.avatarData, @@ -238,9 +237,8 @@ public class NewGroupConfirmViewController: OWSTableViewController2 { owsFailDebug("Could not create group: \(error)") modalActivityIndicator.dismiss { - // Partial success could create the group on the service. - // This would cause retries to fail with 409. Therefore - // we must rotate the seed after every failure. + // Partial success could create the group on the service. This would cause + // retries to fail with 409. Therefore we rotate the seed after failures. self.newGroupState.deriveNewGroupSeedForRetry() NewGroupConfirmViewController.showCreateErrorUI(error: error) diff --git a/Signal/src/ViewControllers/NewGroupView/NewGroupState.swift b/Signal/src/ViewControllers/NewGroupView/NewGroupState.swift index 1aa2d9dda3..f2ab0a4ccc 100644 --- a/Signal/src/ViewControllers/NewGroupView/NewGroupState.swift +++ b/Signal/src/ViewControllers/NewGroupView/NewGroupState.swift @@ -17,7 +17,7 @@ class NewGroupState { var avatarData: Data? func deriveNewGroupSeedForRetry() { - groupSeed = groupSeed.deriveNewGroupSeedForRetry + groupSeed = NewGroupSeed() } var hasUnsavedChanges: Bool { diff --git a/SignalServiceKit/Groups/NewGroupSeed.swift b/SignalServiceKit/Groups/NewGroupSeed.swift index 149da17e5d..da3f6c9748 100644 --- a/SignalServiceKit/Groups/NewGroupSeed.swift +++ b/SignalServiceKit/Groups/NewGroupSeed.swift @@ -12,38 +12,10 @@ public import LibSignalClient // the "new group" view. public struct NewGroupSeed { - public let groupIdV1: Data - public let groupIdV2: Data public let groupSecretParams: GroupSecretParams public init() { - self.init(groupIdV1: TSGroupModel.generateRandomGroupId(.V1)) - } - - private init(groupIdV1: Data) { - self.groupIdV1 = groupIdV1 let groupSecretParams = try! GroupSecretParams.generate() self.groupSecretParams = groupSecretParams - self.groupIdV2 = try! groupSecretParams.getPublicParams().getGroupIdentifier().serialize().asData - } - - public var deriveNewGroupSeedForRetry: NewGroupSeed { - // If group creation fails, we generate a new seed before retrying. - // We want to re-use the same group id for v1 but generate a new - // group id / group secret params for v2. - // - // v1 group creation can fail after having informed some of the members - // and/or inserting the group into the local database. - // In this case, it's important that retries use the same group id. - // Otherwise members may see multiple groups created. - // - // v2 group creation will never fail after having informed some of the - // members and/or inserting the group into the local database. - // However, v2 group creation can fail before or after the group is - // created on the service. (Re-)trying to create the group on the - // service a second time using the same group id/secrets params will - // fail, so it's best to generate a new group id / group secret params - // for v2. - NewGroupSeed(groupIdV1: groupIdV1) } }