-
Notifications
You must be signed in to change notification settings - Fork 19
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
List batch messages takes query parameter #77
Conversation
This reverts commit a31935a.
export type Query = { | ||
startTime?: Date | undefined; | ||
endTime?: Date | undefined; | ||
contentTopic: string; | ||
pageSize?: number | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type matches the JS type.
AsyncFunction("loadMessages") { clientAddress: String, topic: String, limit: Int?, before: Long?, after: Long? -> | ||
logV("loadMessages") | ||
val client = clients[clientAddress] ?: throw XMTPException("No client") | ||
val conversation = | ||
findConversation( | ||
clientAddress = clientAddress, | ||
topic = topic, | ||
) ?: throw XMTPException("no conversation found for $topic") | ||
val beforeDate = if (before != null) Date(before) else null | ||
val afterDate = if (after != null) Date(after) else null | ||
|
||
client.conversations.listBatchMessages(topics, limit, beforeDate, afterDate).map { | ||
conversation.messages(limit = limit, before = beforeDate, after = afterDate) | ||
.map { | ||
EncodedMessageWrapper.encode(it) | ||
} | ||
} | ||
|
||
AsyncFunction("loadBatchMessages") { clientAddress: String, topics: List<String> -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadMessages
- lists all the messages via the envelopesList query inside of the SDKs
loadBatchMessages
- lists all the messages for a batch of topics with given pagination parameters.
These are two different methods in the sdks and should be here as well. Previously both messages, and batch messages called the batch method.
return JSON.stringify({ | ||
limit: item.pageSize || 0, | ||
topic: item.contentTopic, | ||
after: item.startTime?.getTime() || 0, | ||
before: item.endTime?.getTime() || 0, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This converts the javascript type to the JSON string that the SDKS expect.
🎉 This PR is included in version 1.6.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #68
This takes a list of query objects so each topic can have it's own pagination associated with it.
Matches the query type specified in
xmtp-js
https://github.com/xmtp/xmtp-js/blob/main/src/ApiClient.ts#L56-L74Note: This is a breaking change.