Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can message with all addresses #250

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ public final class Client {

return try await v3Client.canMessage(accountAddresses: [address]) == [true]
}

public func canMessageV3(addresses: [String]) async throws -> Bool {
guard let v3Client else {
return false
}

return try await v3Client.canMessage(accountAddresses: addresses) == [true]
}


public static func from(bundle: PrivateKeyBundle, options: ClientOptions? = nil) async throws -> Client {
return try await from(v1Bundle: bundle.v1, options: options)
Expand Down
9 changes: 9 additions & 0 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ class GroupTests: XCTestCase {
XCTAssertEqual(groupChangedMessage.membersRemoved.map(\.accountAddress.localizedLowercase), [fixtures.fred.address.localizedLowercase])
}

func testCanMessage() async throws {
let fixtures = try await localFixtures()
let notOnNetwork = try PrivateKey.generate()
let canMessage = try await fixtures.aliceClient.canMessageV3(addresses: [fixtures.bobClient.address])
let cannotMessage = try await fixtures.aliceClient.canMessageV3(addresses: [notOnNetwork.address])
XCTAssert(canMessage)
XCTAssert(!cannotMessage)
}

func testIsActive() async throws {
let fixtures = try await localFixtures()
let group = try await fixtures.aliceClient.conversations.newGroup(with: [fixtures.bob.address, fixtures.fred.address])
Expand Down
Loading