From 1cb83183324a82fabcb48d0b8c7dd3cfe470e09c Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 1 Nov 2023 11:21:26 -0700 Subject: [PATCH] set state to allow automatically for sending message to conversation --- .../src/main/java/org/xmtp/android/library/ConversationV1.kt | 3 +++ .../src/main/java/org/xmtp/android/library/ConversationV2.kt | 3 +++ 2 files changed, 6 insertions(+) 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 cb42f0b75..8cd10cb50 100644 --- a/library/src/main/java/org/xmtp/android/library/ConversationV1.kt +++ b/library/src/main/java/org/xmtp/android/library/ConversationV1.kt @@ -107,6 +107,9 @@ data class ConversationV1( fun send(prepared: PreparedMessage): String { client.publish(envelopes = prepared.envelopes) + if (client.contacts.consentList.state(address = peerAddress) == ConsentState.UNKNOWN) { + client.contacts.allow(addresses = listOf(peerAddress)) + } return prepared.messageId } 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 add87e246..1e4388b36 100644 --- a/library/src/main/java/org/xmtp/android/library/ConversationV2.kt +++ b/library/src/main/java/org/xmtp/android/library/ConversationV2.kt @@ -119,6 +119,9 @@ data class ConversationV2( fun send(prepared: PreparedMessage): String { client.publish(envelopes = prepared.envelopes) + if (client.contacts.consentList.state(address = peerAddress) == ConsentState.UNKNOWN) { + client.contacts.allow(addresses = listOf(peerAddress)) + } return prepared.messageId }