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 ecfda4f commit 08bfedb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 50 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ try await conversation.send("gm")
// Listen for new messages in the conversation
Task {
for await message in try await conversation.streamMessages() {
print("\(message.senderAddress): \(message.body)")
print("\(message.senderInboxId): \(message.body)")
}
}
```
Expand Down Expand Up @@ -193,7 +193,7 @@ let nextPage = try await conversation.messages(limit: 25, before: messages.first

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.

Expand All @@ -202,10 +202,10 @@ The flow returned by the `stream` methods is an asynchronous data stream that se

Task {
for await message in try await conversation.streamMessages() {
if message.senderAddress == client.address {
if message.senderInboxId == client.address {
// This message was sent from me
}
print("New message from \(message.senderAddress): \(message.body)")
print("New message from \(message.senderInboxId): \(message.body)")
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions Sources/XMTPiOS/DecodedMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct DecodedMessage: Sendable {
public var encodedContent: EncodedContent

/// The wallet address of the sender of the message
public var senderAddress: String
public var senderInboxId: String

/// When the message was sent
public var sent: Date
Expand All @@ -24,7 +24,7 @@ public struct DecodedMessage: Sendable {
client: Client,
topic: String,
encodedContent: EncodedContent,
senderAddress: String,
senderInboxId: String,
sent: Date,
sentNs: Int64,
deliveryStatus: MessageDeliveryStatus = .published
Expand All @@ -33,7 +33,7 @@ public struct DecodedMessage: Sendable {
self.client = client
self.topic = topic
self.encodedContent = encodedContent
self.senderAddress = senderAddress
self.senderInboxId = senderInboxId
self.sent = sent
self.sentNs = sentNs
self.deliveryStatus = deliveryStatus
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMTPiOS/Libxmtp/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public struct Message: Identifiable {
client: client,
topic: Topic.groupMessage(convoId).description,
encodedContent: encodedContent,
senderAddress: senderInboxId,
senderInboxId: senderInboxId,
sent: sentAt,
sentNs: sentAtNs,
deliveryStatus: deliveryStatus
Expand Down
14 changes: 7 additions & 7 deletions XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ struct MessageTextView: View {
var body: some View {
VStack {
HStack {
if message.senderAddress.lowercased() == myAddress.lowercased() {
if message.senderInboxId.lowercased() == myAddress.lowercased() {
Spacer()
}
VStack(alignment: .leading) {
if isGroup && message.senderAddress.lowercased() != myAddress.lowercased() {
Text(message.senderAddress)
if isGroup && message.senderInboxId.lowercased() != myAddress.lowercased() {
Text(message.senderInboxId)
.font(.caption)
.foregroundStyle(.secondary)
}
Expand All @@ -32,7 +32,7 @@ struct MessageTextView: View {
if isDebugging {
Text("My Address \(myAddress)")
.font(.caption)
Text("Sender Address \(message.senderAddress)")
Text("Sender Address \(message.senderInboxId)")
.font(.caption)
}
}
Expand All @@ -46,7 +46,7 @@ struct MessageTextView: View {
isDebugging.toggle()
}
}
if message.senderAddress.lowercased() != myAddress.lowercased() {
if message.senderInboxId.lowercased() != myAddress.lowercased() {
Spacer()
}
}
Expand All @@ -62,15 +62,15 @@ struct MessageTextView: View {
}

var background: Color {
if message.senderAddress.lowercased() == myAddress.lowercased() {
if message.senderInboxId.lowercased() == myAddress.lowercased() {
return .purple
} else {
return .secondary.opacity(0.2)
}
}

var color: Color {
if message.senderAddress.lowercased() == myAddress.lowercased() {
if message.senderInboxId.lowercased() == myAddress.lowercased() {
return .white
} else {
return .primary
Expand Down
35 changes: 0 additions & 35 deletions dev/local/test/script.js

This file was deleted.

0 comments on commit 08bfedb

Please sign in to comment.