Skip to content

Commit

Permalink
sender address needs to be senderInboxId
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 18, 2024
1 parent 5039163 commit edd8e3e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
```

Expand Down Expand Up @@ -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}")
}
```

Expand Down
6 changes: 3 additions & 3 deletions dev/local/test/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit edd8e3e

Please sign in to comment.