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 778b8a01..3084c3d3 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversation.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversation.kt @@ -72,6 +72,13 @@ sealed class Conversation { } } + fun prepareMessage(encodedContent: EncodedContent): String { + return when (this) { + is Group -> group.prepareMessage(encodedContent) + is Dm -> dm.prepareMessage(encodedContent) + } + } + suspend fun send(content: T, options: SendOptions? = null): String { return when (this) { is Group -> group.send(content = content, options = options) 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 5eb6dbcc..4b3f02b5 100644 --- a/library/src/main/java/org/xmtp/android/library/Dm.kt +++ b/library/src/main/java/org/xmtp/android/library/Dm.kt @@ -79,6 +79,13 @@ class Dm(val client: Client, private val libXMTPGroup: FfiConversation) { } } + fun prepareMessage(encodedContent: EncodedContent): String { + if (consentState() == ConsentState.UNKNOWN) { + updateConsentState(ConsentState.ALLOWED) + } + return libXMTPGroup.sendOptimistic(encodedContent.toByteArray()).toHex() + } + fun prepareMessage(content: T, options: SendOptions? = null): String { if (consentState() == ConsentState.UNKNOWN) { updateConsentState(ConsentState.ALLOWED) 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 5d362ba9..91392caa 100644 --- a/library/src/main/java/org/xmtp/android/library/Group.kt +++ b/library/src/main/java/org/xmtp/android/library/Group.kt @@ -96,6 +96,13 @@ class Group(val client: Client, private val libXMTPGroup: FfiConversation) { } } + fun prepareMessage(encodedContent: EncodedContent): String { + if (consentState() == ConsentState.UNKNOWN) { + updateConsentState(ConsentState.ALLOWED) + } + return libXMTPGroup.sendOptimistic(encodedContent.toByteArray()).toHex() + } + fun prepareMessage(content: T, options: SendOptions? = null): String { if (consentState() == ConsentState.UNKNOWN) { updateConsentState(ConsentState.ALLOWED)