Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate `shouldPush' for React Native #184

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ data class ConversationV2(
topic = topic,
keyMaterial = keyMaterial,
codec = codec,
shouldPush = options?.shouldPush
)

val newTopic = if (options?.ephemeral == true) ephemeralTopic else topic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import org.xmtp.proto.message.contents.Content
data class SendOptions(
var compression: EncodedContentCompression? = null,
var contentType: Content.ContentTypeId? = null,
var ephemeral: Boolean = false
var ephemeral: Boolean = false,
var shouldPush: Boolean? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ data class DecryptedMessage(
var encodedContent: EncodedContent,
var senderAddress: String,
var sentAt: Date,
var topic: String = ""
var topic: String = "",
var shouldPush: Boolean?
)
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class MessageV2Builder(val senderHmac: ByteArray? = null, val shouldPush: Boolea
topic: String,
keyMaterial: ByteArray,
codec: Codec,
shouldPush: Boolean? = null
): MessageV2Builder {
val payload = encodedContent.toByteArray()
val date = Date()
Expand All @@ -160,12 +161,13 @@ class MessageV2Builder(val senderHmac: ByteArray? = null, val shouldPush: Boolea
Crypto.deriveKey(keyMaterial, ByteArray(0), infoEncoded),
headerBytes
)
val calculatedShouldPush = shouldPush ?: shouldPush(codec = codec, content = codec.decode(encodedContent))

return buildFromCipherText(
headerBytes,
ciphertext,
senderHmacGenerated,
shouldPush(codec = codec, content = codec.decode(encodedContent)),
calculatedShouldPush,
)
}
}
Expand Down
Loading