Skip to content

Commit

Permalink
Remove timestamp from read receipts (#118)
Browse files Browse the repository at this point in the history
* change the read reciept to no longer include a timestamp paramater

* fix linter issues
  • Loading branch information
nplasterer authored Sep 15, 2023
1 parent 84a6620 commit 986ca27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ReadReceiptTest {

aliceConversation.send(text = "hey alice 2 bob")

val readReceipt = ReadReceipt(timestamp = "2019-09-26T07:58:30.996+0200")
val readReceipt = ReadReceipt

aliceConversation.send(
content = readReceipt,
Expand All @@ -32,8 +32,8 @@ class ReadReceiptTest {
val messages = aliceConversation.messages()
assertEquals(messages.size, 2)
if (messages.size == 2) {
val content: ReadReceipt? = messages.first().content()
assertEquals("2019-09-26T07:58:30.996+0200", content?.timestamp)
val contentType: String = messages.first().encodedContent.type.typeId
assertEquals(contentType, "readReceipt")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.xmtp.android.library.codecs

import com.google.protobuf.ByteString
import org.xmtp.android.library.XMTPException

val ContentTypeReadReceipt = ContentTypeIdBuilder.builderFromAuthorityId(
"xmtp.org",
Expand All @@ -10,26 +9,20 @@ val ContentTypeReadReceipt = ContentTypeIdBuilder.builderFromAuthorityId(
versionMinor = 0
)

data class ReadReceipt(
// The timestamp the read receipt was sent, in ISO 8601 format
val timestamp: String,
)
object ReadReceipt

data class ReadReceiptCodec(override var contentType: ContentTypeId = ContentTypeReadReceipt) :
ContentCodec<ReadReceipt> {

override fun encode(content: ReadReceipt): EncodedContent {
return EncodedContent.newBuilder().also {
it.type = ContentTypeReadReceipt
it.putParameters("timestamp", content.timestamp)
it.content = ByteString.EMPTY
}.build()
}

override fun decode(content: EncodedContent): ReadReceipt {
val timestamp = content.parametersMap["timestamp"] ?: throw XMTPException("Invalid Content")

return ReadReceipt(timestamp = timestamp)
return ReadReceipt
}

override fun fallback(content: ReadReceipt): String? {
Expand Down

0 comments on commit 986ca27

Please sign in to comment.