Remove unused code from NewGroupSeed
This commit is contained in:
parent
d39042ea7d
commit
66fd838dca
@ -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)
|
||||
|
||||
@ -17,7 +17,7 @@ class NewGroupState {
|
||||
var avatarData: Data?
|
||||
|
||||
func deriveNewGroupSeedForRetry() {
|
||||
groupSeed = groupSeed.deriveNewGroupSeedForRetry
|
||||
groupSeed = NewGroupSeed()
|
||||
}
|
||||
|
||||
var hasUnsavedChanges: Bool {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user