Skip to content

Commit

Permalink
fix: make the can message function return a map of addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Apr 24, 2024
1 parent c691501 commit 10b3f25
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:0.10.5"
implementation "org.xmtp:android:0.10.6"
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.facebook.react:react-native:0.71.3'
implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,12 @@ class XMTPModule : Module() {
client.canMessage(peerAddress)
}

AsyncFunction("canGroupMessage") { clientAddress: String, peerAddresses: List<String> ->
logV("canGroupMessage")
val client = clients[clientAddress] ?: throw XMTPException("No client")
client.canMessageV3(peerAddresses)
AsyncFunction("canGroupMessage") Coroutine { clientAddress: String, peerAddresses: List<String> ->
withContext(Dispatchers.IO) {
logV("canGroupMessage")
val client = clients[clientAddress] ?: throw XMTPException("No client")
client.canMessageV3(peerAddresses)
}
}

AsyncFunction("staticCanMessage") { peerAddress: String, environment: String, appVersion: String? ->
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export async function canMessage(
export async function canGroupMessage(
clientAddress: string,
peerAddresses: string[]
): Promise<boolean> {
): Promise<{ [key: string]: boolean }> {
return await XMTPModule.canGroupMessage(clientAddress, peerAddresses)
}

Expand Down
6 changes: 4 additions & 2 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ export class Client<
* This method checks if the specified peers are using clients that support group messaging.
*
* @param {string[]} addresses - The addresses of the peers to check for messaging eligibility.
* @returns {Promise<boolean[]>} A Promise resolving to true for peers where group messaging is allowed, and false otherwise.
* @returns {Promise<{ [key: string]: boolean }>} A Promise resolving to a hash of addresses and booleans if they can message on the V3 network.
*/
async canGroupMessage(addresses: string[]): Promise<boolean> {
async canGroupMessage(
addresses: string[]
): Promise<{ [key: string]: boolean }> {
return await XMTPModule.canGroupMessage(this.address, addresses)
}

Expand Down

0 comments on commit 10b3f25

Please sign in to comment.