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 4eb2617b8..be2a8b208 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt @@ -164,7 +164,7 @@ class DmTest { assertEquals(dm.messages().first().body, "gm") assertEquals(dm.messages().first().id, messageId) assertEquals(dm.messages().first().deliveryStatus, MessageDeliveryStatus.PUBLISHED) - assertEquals(dm.messages().size, 3) + assertEquals(dm.messages().size, 2) runBlocking { alixClient.conversations.syncConversations() } val sameDm = runBlocking { alixClient.conversations.listDms().last() } @@ -181,12 +181,12 @@ class DmTest { dm.send("gm") } - assertEquals(dm.messages().size, 3) - assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 3) + assertEquals(dm.messages().size, 2) + assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 2) runBlocking { dm.sync() } - assertEquals(dm.messages().size, 3) + assertEquals(dm.messages().size, 2) assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.UNPUBLISHED).size, 0) - assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 3) + assertEquals(dm.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 2) runBlocking { alixClient.conversations.syncConversations() } val sameDm = runBlocking { alixClient.conversations.listDms().last() } @@ -219,7 +219,7 @@ class DmTest { runBlocking { dm.sync() } val messages = dm.messages() - assertEquals(messages.size, 3) + assertEquals(messages.size, 2) val content: Reaction? = messages.first().content() assertEquals("U+1F603", content?.content) assertEquals(messageToReact.id, content?.reference) 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 064996384..dbb746217 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -37,6 +37,8 @@ import org.xmtp.android.library.messages.walletAddress import org.xmtp.proto.message.api.v1.MessageApiOuterClass import org.xmtp.proto.message.api.v1.MessageApiOuterClass.BatchQueryResponse import org.xmtp.proto.message.api.v1.MessageApiOuterClass.QueryRequest +import uniffi.xmtpv3.FfiConversationType +import uniffi.xmtpv3.FfiDeviceSyncKind import uniffi.xmtpv3.FfiV2SubscribeRequest import uniffi.xmtpv3.FfiV2Subscription import uniffi.xmtpv3.FfiV2SubscriptionCallback @@ -616,12 +618,10 @@ class Client() { fun findConversation(conversationId: String): Conversation? { val client = v3Client ?: throw XMTPException("Error no V3 client initialized") val conversation = client.conversation(conversationId.hexToByteArray()) - return if (conversation.groupMetadata().conversationType() == "dm") { - Conversation.Dm(Dm(this, conversation)) - } else if (conversation.groupMetadata().conversationType() == "group") { - Conversation.Group(Group(this, conversation)) - } else { - null + return when (conversation.conversationType()) { + FfiConversationType.GROUP -> Conversation.Group(Group(this, conversation)) + FfiConversationType.DM -> Conversation.Dm(Dm(this, conversation)) + else -> null } } @@ -631,12 +631,10 @@ class Client() { val matchResult = regex.find(topic) val conversationId = matchResult?.groupValues?.get(1) ?: "" val conversation = client.conversation(conversationId.hexToByteArray()) - return if (conversation.groupMetadata().conversationType() == "dm") { - Conversation.Dm(Dm(this, conversation)) - } else if (conversation.groupMetadata().conversationType() == "group") { - Conversation.Group(Group(this, conversation)) - } else { - null + return when (conversation.conversationType()) { + FfiConversationType.GROUP -> Conversation.Group(Group(this, conversation)) + FfiConversationType.DM -> Conversation.Dm(Dm(this, conversation)) + else -> null } } @@ -775,7 +773,7 @@ class Client() { } suspend fun requestMessageHistorySync() { - v3Client?.requestHistorySync() ?: throw XMTPException("Error no V3 client initialized") + v3Client?.sendSyncRequest(FfiDeviceSyncKind.MESSAGES) ?: throw XMTPException("Error no V3 client initialized") } suspend fun revokeAllOtherInstallations(signingKey: SigningKey) { diff --git a/library/src/main/java/org/xmtp/android/library/ConversationV1.kt b/library/src/main/java/org/xmtp/android/library/ConversationV1.kt index 2d031b5fe..9dcf67a79 100644 --- a/library/src/main/java/org/xmtp/android/library/ConversationV1.kt +++ b/library/src/main/java/org/xmtp/android/library/ConversationV1.kt @@ -27,6 +27,7 @@ import org.xmtp.android.library.messages.walletAddress import org.xmtp.proto.message.api.v1.MessageApiOuterClass import uniffi.xmtpv3.FfiEnvelope import uniffi.xmtpv3.FfiV2SubscriptionCallback +import uniffi.xmtpv3.GenericException import java.util.Date data class ConversationV1( @@ -49,6 +50,9 @@ data class ConversationV1( override fun onMessage(message: FfiEnvelope) { trySend(decode(envelope = envelopeFromFFi(message))) } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe(listOf(topic.description), streamCallback) awaitClose { launch { stream.end() } } @@ -283,6 +287,9 @@ data class ConversationV1( override fun onMessage(message: FfiEnvelope) { trySend(envelopeFromFFi(message)) } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe(listOf(ephemeralTopic), streamCallback) awaitClose { launch { stream.end() } } @@ -293,6 +300,9 @@ data class ConversationV1( override fun onMessage(message: FfiEnvelope) { trySend(decrypt(envelope = envelopeFromFFi(message))) } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe(listOf(topic.description), streamCallback) awaitClose { launch { stream.end() } } diff --git a/library/src/main/java/org/xmtp/android/library/ConversationV2.kt b/library/src/main/java/org/xmtp/android/library/ConversationV2.kt index 981934d8f..b299665e0 100644 --- a/library/src/main/java/org/xmtp/android/library/ConversationV2.kt +++ b/library/src/main/java/org/xmtp/android/library/ConversationV2.kt @@ -24,6 +24,7 @@ import org.xmtp.proto.message.api.v1.MessageApiOuterClass import org.xmtp.proto.message.contents.Invitation import uniffi.xmtpv3.FfiEnvelope import uniffi.xmtpv3.FfiV2SubscriptionCallback +import uniffi.xmtpv3.GenericException import java.util.Date data class ConversationV2( @@ -149,6 +150,9 @@ data class ConversationV2( trySend(it) } } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe(listOf(topic), streamCallback) awaitClose { launch { stream.end() } } @@ -284,6 +288,9 @@ data class ConversationV2( override fun onMessage(message: FfiEnvelope) { trySend(Util.envelopeFromFFi(message)) } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe(listOf(ephemeralTopic), streamCallback) awaitClose { launch { stream.end() } } @@ -294,6 +301,9 @@ data class ConversationV2( override fun onMessage(message: FfiEnvelope) { trySend(decrypt(envelope = Util.envelopeFromFFi(message))) } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe(listOf(topic), streamCallback) awaitClose { launch { stream.end() } } 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 a346cc710..c68e0f362 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversations.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversations.kt @@ -39,6 +39,7 @@ import org.xmtp.proto.message.contents.Contact import org.xmtp.proto.message.contents.Invitation import uniffi.xmtpv3.FfiConversation import uniffi.xmtpv3.FfiConversationCallback +import uniffi.xmtpv3.FfiConversationType import uniffi.xmtpv3.FfiConversations import uniffi.xmtpv3.FfiCreateGroupOptions import uniffi.xmtpv3.FfiDirection @@ -53,6 +54,7 @@ import uniffi.xmtpv3.FfiSubscribeException import uniffi.xmtpv3.FfiV2SubscribeRequest import uniffi.xmtpv3.FfiV2Subscription import uniffi.xmtpv3.FfiV2SubscriptionCallback +import uniffi.xmtpv3.GenericException import uniffi.xmtpv3.NoPointer import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.GroupPermissionPreconfiguration import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionPolicySet @@ -78,7 +80,7 @@ data class Conversations( suspend fun conversationFromWelcome(envelopeBytes: ByteArray): Conversation { val conversation = libXMTPConversations?.processStreamedWelcomeMessage(envelopeBytes) ?: throw XMTPException("Client does not support Groups") - if (conversation.groupMetadata().conversationType() == "dm") { + if (conversation.conversationType() == FfiConversationType.DM) { return Conversation.Dm(Dm(client, conversation)) } else { return Conversation.Group(Group(client, conversation)) @@ -312,7 +314,8 @@ data class Conversations( opts = FfiListConversationsOptions( after?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), before?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), - limit?.toLong() + limit?.toLong(), + null ) ) ?: throw XMTPException("Client does not support V3 dms") @@ -331,7 +334,8 @@ data class Conversations( opts = FfiListConversationsOptions( after?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), before?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), - limit?.toLong() + limit?.toLong(), + null ) ) ?: throw XMTPException("Client does not support V3 dms") @@ -354,7 +358,8 @@ data class Conversations( FfiListConversationsOptions( after?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), before?.time?.nanoseconds?.toLong(DurationUnit.NANOSECONDS), - limit?.toLong() + limit?.toLong(), + null ) ) ?: throw XMTPException("Client does not support V3 dms") @@ -404,7 +409,7 @@ data class Conversations( } private fun FfiConversation.toConversation(): Conversation { - return if (groupMetadata().conversationType() == "dm") { + return if (conversationType() == FfiConversationType.DM) { Conversation.Dm(Dm(client, this)) } else { Conversation.Group(Group(client, this)) @@ -533,6 +538,9 @@ data class Conversations( } } } + + override fun onError(error: GenericException) { + } } val stream = client.subscribe2( @@ -556,7 +564,7 @@ data class Conversations( if (client.hasV2Client) throw XMTPException("Only supported for V3 only clients.") val conversationCallback = object : FfiConversationCallback { override fun onConversation(conversation: FfiConversation) { - if (conversation.groupMetadata().conversationType() == "dm") { + if (conversation.conversationType() == FfiConversationType.DM) { trySend(Conversation.Dm(Dm(client, conversation))) } else { trySend(Conversation.Group(Group(client, conversation))) @@ -963,6 +971,9 @@ data class Conversations( else -> {} } } + + override fun onError(error: GenericException) { + } } stream = client.subscribe2(subscriptionRequest, subscriptionCallback) @@ -1013,6 +1024,9 @@ data class Conversations( else -> {} } } + + override fun onError(error: GenericException) { + } } stream = client.subscribe2(subscriptionRequest, subscriptionCallback) diff --git a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so index 9231ed8f1..a8e8ba509 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 d665be4d3..453e13caf 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 f9084ef1d..27ecfa2c6 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 2e052ea43..72faddf76 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