From edd8e3ecc7925862357110725d8126388c98722c Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Tue, 17 Dec 2024 22:19:47 -0800 Subject: [PATCH] sender address needs to be senderInboxId --- README.md | 8 ++++---- dev/local/test/script.js | 6 +++--- .../example/conversation/ConversationViewHolder.kt | 2 +- .../org/xmtp/android/example/message/MessageViewHolder.kt | 2 +- .../main/java/org/xmtp/android/library/DecodedMessage.kt | 2 +- .../main/java/org/xmtp/android/library/libxmtp/Message.kt | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9f12a0eec..996d52a7f 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ conversation.send(text = "gm") // Listen for new messages in the conversation conversation.streamMessages().collect { - print("${it.senderAddress}: ${it.body}") + print("${it.senderInboxId}: ${it.body}") } ``` @@ -199,17 +199,17 @@ val nextPage = conversation.messages(limit = 25, beforeNs = messages[0].sentNs) You can listen for any new messages (incoming or outgoing) in a conversation by calling `conversation.streamMessages()`. -A successfully received message (that makes it through the decoding and decryption without throwing) can be trusted to be authentic. Authentic means that it was sent by the owner of the `message.senderAddress` account and that it wasn't modified in transit. The `message.sent` timestamp can be trusted to have been set by the sender. +A successfully received message (that makes it through the decoding and decryption without throwing) can be trusted to be authentic. Authentic means that it was sent by the owner of the `message.senderInboxId` account and that it wasn't modified in transit. The `message.sent` timestamp can be trusted to have been set by the sender. The flow returned by the `stream` methods is an asynchronous data stream that sequentially emits values and completes normally or with an exception. ```kotlin conversation.streamMessages().collect { - if (it.senderAddress == client.address) { + if (it.senderInboxId == client.address) { // This message was sent from me } - print("New message from ${it.senderAddress}: ${it.body}") + print("New message from ${it.senderInboxId}: ${it.body}") } ``` diff --git a/dev/local/test/script.js b/dev/local/test/script.js index 164a446c5..4b98e4071 100644 --- a/dev/local/test/script.js +++ b/dev/local/test/script.js @@ -19,12 +19,12 @@ async function checkAll() { try { for await (const message of await client.conversations.streamAllMessages()) { - if (message.senderAddress === wallet.address) { + if (message.senderInboxId === wallet.address) { continue; } - await message.conversation.send("HI " + message.senderAddress); - console.log(`Replied to ${message.senderAddress}`); + await message.conversation.send("HI " + message.senderInboxId); + console.log(`Replied to ${message.senderInboxId}`); } } catch (e) { console.info(`Error:`, e); diff --git a/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt b/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt index fa76a042e..79ac7c567 100644 --- a/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt +++ b/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt @@ -39,7 +39,7 @@ class ConversationViewHolder( } else { "" } - val isMe = item.mostRecentMessage?.senderAddress == ClientManager.client.address + val isMe = item.mostRecentMessage?.senderInboxId == ClientManager.client.address if (messageBody.isNotBlank()) { binding.messageBody.text = if (isMe) binding.root.resources.getString( R.string.your_message_body, diff --git a/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt b/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt index f9814a4b3..58a67f086 100644 --- a/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt +++ b/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt @@ -28,7 +28,7 @@ class MessageViewHolder( @SuppressLint("SetTextI18n") fun bind(item: ConversationDetailViewModel.MessageListItem.Message) { val isFromMe = - ClientManager.client.address.lowercase() == item.message.senderAddress.lowercase() + ClientManager.client.address.lowercase() == item.message.senderInboxId.lowercase() val params = binding.messageContainer.layoutParams as ConstraintLayout.LayoutParams if (isFromMe) { params.rightToRight = PARENT_ID diff --git a/library/src/main/java/org/xmtp/android/library/DecodedMessage.kt b/library/src/main/java/org/xmtp/android/library/DecodedMessage.kt index fa0358f48..bff236239 100644 --- a/library/src/main/java/org/xmtp/android/library/DecodedMessage.kt +++ b/library/src/main/java/org/xmtp/android/library/DecodedMessage.kt @@ -10,7 +10,7 @@ data class DecodedMessage( val client: Client, var topic: String, var encodedContent: Content.EncodedContent, - var senderAddress: String, + var senderInboxId: String, var sent: Date, var sentNs: Long, var deliveryStatus: MessageDeliveryStatus = MessageDeliveryStatus.PUBLISHED diff --git a/library/src/main/java/org/xmtp/android/library/libxmtp/Message.kt b/library/src/main/java/org/xmtp/android/library/libxmtp/Message.kt index 6374a211c..1537c99dd 100644 --- a/library/src/main/java/org/xmtp/android/library/libxmtp/Message.kt +++ b/library/src/main/java/org/xmtp/android/library/libxmtp/Message.kt @@ -52,7 +52,7 @@ data class Message(val client: Client, private val libXMTPMessage: FfiMessage) { client = client, topic = Topic.groupMessage(convoId).description, encodedContent = EncodedContent.parseFrom(libXMTPMessage.content), - senderAddress = senderInboxId, + senderInboxId = senderInboxId, sent = sentAt, sentNs = sentAtNs, deliveryStatus = deliveryStatus