Skip to content

Commit

Permalink
add prepare for encoded content
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 16, 2024
1 parent a47853a commit 8bef5ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> send(content: T, options: SendOptions? = null): String {
return when (this) {
is Group -> group.send(content = content, options = options)
Expand Down
4 changes: 4 additions & 0 deletions library/src/main/java/org/xmtp/android/library/Dm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class Dm(val client: Client, private val libXMTPGroup: FfiConversation) {
}
}

fun prepareMessage(encodedContent: EncodedContent): String {
return libXMTPGroup.sendOptimistic(encodedContent.toByteArray()).toHex()
}

fun <T> prepareMessage(content: T, options: SendOptions? = null): String {
if (consentState() == ConsentState.UNKNOWN) {
updateConsentState(ConsentState.ALLOWED)
Expand Down
4 changes: 4 additions & 0 deletions library/src/main/java/org/xmtp/android/library/Group.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class Group(val client: Client, private val libXMTPGroup: FfiConversation) {
}
}

fun prepareMessage(encodedContent: EncodedContent): String {
return libXMTPGroup.sendOptimistic(encodedContent.toByteArray()).toHex()
}

fun <T> prepareMessage(content: T, options: SendOptions? = null): String {
if (consentState() == ConsentState.UNKNOWN) {
updateConsentState(ConsentState.ALLOWED)
Expand Down

0 comments on commit 8bef5ec

Please sign in to comment.