Skip to content

Commit

Permalink
allow one-person groups (#334)
Browse files Browse the repository at this point in the history
* remove guard against empty groups

* add canStartEmtpyGroup test
  • Loading branch information
peterferguson authored May 8, 2024
1 parent 687ecd3 commit 3f47ab8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 1 addition & 6 deletions Sources/XMTPiOS/Conversations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ public enum ConversationError: Error, CustomStringConvertible {
}

public enum GroupError: Error, CustomStringConvertible {
case alphaMLSNotEnabled, emptyCreation, memberCannotBeSelf, memberNotRegistered([String]), groupsRequireMessagePassed, notSupportedByGroups
case alphaMLSNotEnabled, memberCannotBeSelf, memberNotRegistered([String]), groupsRequireMessagePassed, notSupportedByGroups

public var description: String {
switch self {
case .alphaMLSNotEnabled:
return "GroupError.alphaMLSNotEnabled"
case .emptyCreation:
return "GroupError.emptyCreation you cannot create an empty group"
case .memberCannotBeSelf:
return "GroupError.memberCannotBeSelf you cannot add yourself to a group"
case .memberNotRegistered(let array):
Expand Down Expand Up @@ -120,9 +118,6 @@ public actor Conversations {
throw GroupError.alphaMLSNotEnabled
}

if addresses.isEmpty {
throw GroupError.emptyCreation
}

if addresses.first(where: { $0.lowercased() == client.address.lowercased() }) != nil {
throw GroupError.memberCannotBeSelf
Expand Down
8 changes: 3 additions & 5 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,10 @@ class GroupTests: XCTestCase {
)
}

func testCannotStartEmptyGroup() async throws {
func testCanStartEmptyGroup() async throws {
let fixtures = try await localFixtures()

await assertThrowsAsyncError(
try await fixtures.aliceClient.conversations.newGroup(with: [])
)
let group = try await fixtures.aliceClient.conversations.newGroup(with: [])
XCTAssert(!group.id.isEmpty)
}

func testCannotStartGroupWithNonRegisteredIdentity() async throws {
Expand Down

0 comments on commit 3f47ab8

Please sign in to comment.