diff --git a/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt b/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt index 07dde0b08..60b38614c 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt @@ -69,7 +69,9 @@ class DmTest { @Test fun testCanCreateADm() { - + val dm = runBlocking { + boClient.conversations.newConversation(alix.walletAddress) + } } @Test fun testCanListDmMembers() { diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index f45146a68..18d9b0acf 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -567,10 +567,20 @@ class Client() { } } + @Deprecated("Find now includes DMs and Groups", replaceWith = ReplaceWith("findConversation")) fun findGroup(groupId: String): Group? { val client = v3Client ?: throw XMTPException("Error no V3 client initialized") try { - return Group(this, client.group(groupId.hexToByteArray())) + return Group(this, client.conversation(groupId.hexToByteArray())) + } catch (e: Exception) { + return null + } + } + + fun findConversation(conversationId: String): Group? { + val client = v3Client ?: throw XMTPException("Error no V3 client initialized") + try { + return Group(this, client.conversation(conversationId.hexToByteArray())) } catch (e: Exception) { return null } diff --git a/library/src/main/java/org/xmtp/android/library/Contacts.kt b/library/src/main/java/org/xmtp/android/library/Contacts.kt index 05df91cee..c0d0b544a 100644 --- a/library/src/main/java/org/xmtp/android/library/Contacts.kt +++ b/library/src/main/java/org/xmtp/android/library/Contacts.kt @@ -47,7 +47,7 @@ enum class EntryType { fun toFfiConsentEntityType(option: EntryType): FfiConsentEntityType { return when (option) { EntryType.ADDRESS -> FfiConsentEntityType.ADDRESS - EntryType.GROUP_ID -> FfiConsentEntityType.GROUP_ID + EntryType.GROUP_ID -> FfiConsentEntityType.CONVERSATION_ID EntryType.INBOX_ID -> FfiConsentEntityType.INBOX_ID } } @@ -55,7 +55,7 @@ enum class EntryType { fun fromFfiConsentEntityType(option: FfiConsentEntityType): EntryType { return when (option) { FfiConsentEntityType.ADDRESS -> EntryType.ADDRESS - FfiConsentEntityType.GROUP_ID -> EntryType.GROUP_ID + FfiConsentEntityType.CONVERSATION_ID -> EntryType.GROUP_ID FfiConsentEntityType.INBOX_ID -> EntryType.INBOX_ID } } @@ -301,7 +301,7 @@ class ConsentList( client.v3Client?.let { return ConsentState.fromFfiConsentState( it.getConsentState( - FfiConsentEntityType.GROUP_ID, + FfiConsentEntityType.CONVERSATION_ID, groupId ) ) diff --git a/library/src/main/java/org/xmtp/android/library/Conversations.kt b/library/src/main/java/org/xmtp/android/library/Conversations.kt index 69173f023..4a3f463e0 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversations.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversations.kt @@ -40,7 +40,7 @@ import uniffi.xmtpv3.FfiConversationCallback import uniffi.xmtpv3.FfiConversations import uniffi.xmtpv3.FfiCreateGroupOptions import uniffi.xmtpv3.FfiEnvelope -import uniffi.xmtpv3.FfiGroup +import uniffi.xmtpv3.FfiConversation import uniffi.xmtpv3.FfiListConversationsOptions import uniffi.xmtpv3.FfiMessage import uniffi.xmtpv3.FfiMessageCallback @@ -191,9 +191,15 @@ data class Conversations( libXMTPConversations?.sync() } + // Sync all existing local conversation data from the network (Note: call syncConversations() first to get the latest list of conversations) + suspend fun syncAllConversations(): UInt? { + return libXMTPConversations?.syncAllConversations() + } + // Sync all existing local groups data from the network (Note: call syncGroups() first to get the latest list of groups) + @Deprecated("Sync now includes DMs and Groups", replaceWith = ReplaceWith("syncAllConversations")) suspend fun syncAllGroups(): UInt? { - return libXMTPConversations?.syncAllGroups() + return libXMTPConversations?.syncAllConversations() } suspend fun listGroups( @@ -201,7 +207,7 @@ data class Conversations( before: Date? = null, limit: Int? = null, ): List { - return libXMTPConversations?.list( + return libXMTPConversations?.listGroups( opts = FfiListConversationsOptions( after?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), before?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), @@ -670,22 +676,22 @@ data class Conversations( private fun streamGroupConversations(): Flow = callbackFlow { val groupCallback = object : FfiConversationCallback { - override fun onConversation(conversation: FfiGroup) { + override fun onConversation(conversation: FfiConversation) { trySend(Conversation.Group(Group(client, conversation))) } } - val stream = libXMTPConversations?.stream(groupCallback) + val stream = libXMTPConversations?.streamGroups(groupCallback) ?: throw XMTPException("Client does not support Groups") awaitClose { stream.end() } } fun streamGroups(): Flow = callbackFlow { val groupCallback = object : FfiConversationCallback { - override fun onConversation(conversation: FfiGroup) { + override fun onConversation(conversation: FfiConversation) { trySend(Group(client, conversation)) } } - val stream = libXMTPConversations?.stream(groupCallback) + val stream = libXMTPConversations?.streamGroups(groupCallback) ?: throw XMTPException("Client does not support Groups") awaitClose { stream.end() } } @@ -699,7 +705,7 @@ data class Conversations( } } } - val stream = libXMTPConversations?.streamAllMessages(messageCallback) + val stream = libXMTPConversations?.streamAllGroupMessages(messageCallback) ?: throw XMTPException("Client does not support Groups") awaitClose { stream.end() } } @@ -713,7 +719,7 @@ data class Conversations( } } } - val stream = libXMTPConversations?.streamAllMessages(messageCallback) + val stream = libXMTPConversations?.streamAllGroupMessages(messageCallback) ?: throw XMTPException("Client does not support Groups") awaitClose { stream.end() } } diff --git a/library/src/main/java/org/xmtp/android/library/Dm.kt b/library/src/main/java/org/xmtp/android/library/Dm.kt index 78eb04919..b3359c8d7 100644 --- a/library/src/main/java/org/xmtp/android/library/Dm.kt +++ b/library/src/main/java/org/xmtp/android/library/Dm.kt @@ -13,22 +13,17 @@ import org.xmtp.android.library.messages.MessageDeliveryStatus import org.xmtp.android.library.messages.PagingInfoSortDirection import org.xmtp.android.library.messages.Topic import org.xmtp.proto.message.api.v1.MessageApiOuterClass +import uniffi.xmtpv3.FfiConversation +import uniffi.xmtpv3.FfiConversationMetadata import uniffi.xmtpv3.FfiDeliveryStatus -import uniffi.xmtpv3.FfiGroup -import uniffi.xmtpv3.FfiGroupMetadata -import uniffi.xmtpv3.FfiGroupPermissions import uniffi.xmtpv3.FfiListMessagesOptions import uniffi.xmtpv3.FfiMessage import uniffi.xmtpv3.FfiMessageCallback -import uniffi.xmtpv3.FfiMetadataField -import uniffi.xmtpv3.FfiPermissionUpdateType -import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption -import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionPolicySet import java.util.Date import kotlin.time.Duration.Companion.nanoseconds import kotlin.time.DurationUnit -class Dm(val client: Client, private val libXMTPGroup: FfiGroup) { +class Dm(val client: Client, private val libXMTPGroup: FfiConversation) { val id: String get() = libXMTPGroup.id().toHex() @@ -38,7 +33,7 @@ class Dm(val client: Client, private val libXMTPGroup: FfiGroup) { val createdAt: Date get() = Date(libXMTPGroup.createdAtNs() / 1_000_000) - private val metadata: FfiGroupMetadata + private val metadata: FfiConversationMetadata get() = libXMTPGroup.groupMetadata() val name: String @@ -171,7 +166,7 @@ class Dm(val client: Client, private val libXMTPGroup: FfiGroup) { } suspend fun processMessage(envelopeBytes: ByteArray): MessageV3 { - val message = libXMTPGroup.processStreamedGroupMessage(envelopeBytes) + val message = libXMTPGroup.processStreamedConversationMessage(envelopeBytes) return MessageV3(client, message) } 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 176a25f8f..0fa3bfb35 100644 --- a/library/src/main/java/org/xmtp/android/library/Group.kt +++ b/library/src/main/java/org/xmtp/android/library/Group.kt @@ -14,8 +14,8 @@ import org.xmtp.android.library.messages.PagingInfoSortDirection import org.xmtp.android.library.messages.Topic import org.xmtp.proto.message.api.v1.MessageApiOuterClass import uniffi.xmtpv3.FfiDeliveryStatus -import uniffi.xmtpv3.FfiGroup -import uniffi.xmtpv3.FfiGroupMetadata +import uniffi.xmtpv3.FfiConversation +import uniffi.xmtpv3.FfiConversationMetadata import uniffi.xmtpv3.FfiGroupPermissions import uniffi.xmtpv3.FfiListMessagesOptions import uniffi.xmtpv3.FfiMessage @@ -28,7 +28,7 @@ import java.util.Date import kotlin.time.Duration.Companion.nanoseconds import kotlin.time.DurationUnit -class Group(val client: Client, private val libXMTPGroup: FfiGroup) { +class Group(val client: Client, private val libXMTPGroup: FfiConversation) { val id: String get() = libXMTPGroup.id().toHex() @@ -38,7 +38,7 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) { val createdAt: Date get() = Date(libXMTPGroup.createdAtNs() / 1_000_000) - private val metadata: FfiGroupMetadata + private val metadata: FfiConversationMetadata get() = libXMTPGroup.groupMetadata() private val permissions: FfiGroupPermissions @@ -174,7 +174,7 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) { } suspend fun processMessage(envelopeBytes: ByteArray): MessageV3 { - val message = libXMTPGroup.processStreamedGroupMessage(envelopeBytes) + val message = libXMTPGroup.processStreamedConversationMessage(envelopeBytes) return MessageV3(client, message) } diff --git a/library/src/main/java/org/xmtp/android/library/libxmtp/Member.kt b/library/src/main/java/org/xmtp/android/library/libxmtp/Member.kt index c502247a6..c8ca6c85e 100644 --- a/library/src/main/java/org/xmtp/android/library/libxmtp/Member.kt +++ b/library/src/main/java/org/xmtp/android/library/libxmtp/Member.kt @@ -1,13 +1,13 @@ package org.xmtp.android.library.libxmtp import org.xmtp.android.library.ConsentState -import uniffi.xmtpv3.FfiGroupMember +import uniffi.xmtpv3.FfiConversationMember import uniffi.xmtpv3.FfiPermissionLevel enum class PermissionLevel { MEMBER, ADMIN, SUPER_ADMIN } -class Member(private val ffiMember: FfiGroupMember) { +class Member(private val ffiMember: FfiConversationMember) { val inboxId: String get() = ffiMember.inboxId diff --git a/library/src/main/java/org/xmtp/android/library/libxmtp/MessageV3.kt b/library/src/main/java/org/xmtp/android/library/libxmtp/MessageV3.kt index fc1302b7a..631fd2e5f 100644 --- a/library/src/main/java/org/xmtp/android/library/libxmtp/MessageV3.kt +++ b/library/src/main/java/org/xmtp/android/library/libxmtp/MessageV3.kt @@ -11,7 +11,7 @@ import org.xmtp.android.library.messages.MessageDeliveryStatus import org.xmtp.android.library.messages.Topic import org.xmtp.android.library.toHex import uniffi.xmtpv3.FfiDeliveryStatus -import uniffi.xmtpv3.FfiGroupMessageKind +import uniffi.xmtpv3.FfiConversationMessageKind import uniffi.xmtpv3.FfiMessage import java.util.Date @@ -47,7 +47,7 @@ data class MessageV3(val client: Client, private val libXMTPMessage: FfiMessage) sent = sentAt, deliveryStatus = deliveryStatus ) - if (decodedMessage.encodedContent.type == ContentTypeGroupUpdated && libXMTPMessage.kind != FfiGroupMessageKind.MEMBERSHIP_CHANGE) { + if (decodedMessage.encodedContent.type == ContentTypeGroupUpdated && libXMTPMessage.kind != FfiConversationMessageKind.MEMBERSHIP_CHANGE) { throw XMTPException("Error decoding group membership change") } return decodedMessage diff --git a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so index 903a911ce..630fd8a1f 100644 Binary files a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so differ diff --git a/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so b/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so index 985c74d66..bdac837d3 100644 Binary files a/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so differ diff --git a/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so b/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so index 88d13cb15..54cd00c63 100644 Binary files a/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so differ diff --git a/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so b/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so index 921fbff5f..621d1ea21 100644 Binary files a/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so differ