diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt index 0402a8754..1758f694b 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt @@ -150,6 +150,14 @@ class GroupTest { bo.walletAddress.lowercase() ).sorted() ) + + assertEquals( + Conversation.Group(group).peerAddresses.sorted(), + listOf( + caro.walletAddress.lowercase(), + alix.walletAddress.lowercase(), + ).sorted() + ) } @Test @@ -430,8 +438,7 @@ class GroupTest { ) var result = boClient.contacts.isGroupAllowed(group.id) - - assert(!result) + assert(result) boClient.contacts.allowGroup(listOf(group.id)) @@ -448,8 +455,7 @@ class GroupTest { ) ) var result = boClient.contacts.isGroupAllowed(group.id) - - assert(!result) + assert(result) boClient.contacts.denyGroup(listOf(group.id)) diff --git a/library/src/main/java/org/xmtp/android/library/Conversation.kt b/library/src/main/java/org/xmtp/android/library/Conversation.kt index 506bc3571..51219b3ac 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversation.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversation.kt @@ -55,11 +55,7 @@ sealed class Conversation { return when (this) { is V1 -> conversationV1.peerAddress is V2 -> conversationV2.peerAddress - is Group -> { - val addresses = group.memberAddresses().toMutableList() - addresses.remove(clientAddress) - addresses.joinToString(",") - } + is Group -> group.peerAddresses().joinToString(",") } } @@ -68,11 +64,7 @@ sealed class Conversation { return when (this) { is V1 -> listOf(conversationV1.peerAddress) is V2 -> listOf(conversationV2.peerAddress) - is Group -> { - val addresses = group.memberAddresses().toMutableList() - addresses.remove(clientAddress) - addresses - } + is Group -> group.peerAddresses() } } diff --git a/library/src/main/java/org/xmtp/android/library/Group.kt b/library/src/main/java/org/xmtp/android/library/Group.kt index 99e93c8a1..e2849c8ff 100644 --- a/library/src/main/java/org/xmtp/android/library/Group.kt +++ b/library/src/main/java/org/xmtp/android/library/Group.kt @@ -165,6 +165,12 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) { } } + fun peerAddresses(): List { + val addresses = memberAddresses().map { it.lowercase() }.toMutableList() + addresses.remove(client.address.lowercase()) + return addresses + } + fun streamMessages(): Flow = callbackFlow { val messageCallback = object : FfiMessageCallback { override fun onMessage(message: FfiMessage) {