File tree 2 files changed +5
-12
lines changed
androidTest/java/org/xmtp/android/library
main/java/org/xmtp/android/library/codecs
2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class ReadReceiptTest {
23
23
24
24
aliceConversation.send(text = " hey alice 2 bob" )
25
25
26
- val readReceipt = ReadReceipt (timestamp = " 2019-09-26T07:58:30.996+0200 " )
26
+ val readReceipt = ReadReceipt
27
27
28
28
aliceConversation.send(
29
29
content = readReceipt,
@@ -32,8 +32,8 @@ class ReadReceiptTest {
32
32
val messages = aliceConversation.messages()
33
33
assertEquals(messages.size, 2 )
34
34
if (messages.size == 2 ) {
35
- val content : ReadReceipt ? = messages.first().content()
36
- assertEquals(" 2019-09-26T07:58:30.996+0200 " , content?.timestamp )
35
+ val contentType : String = messages.first().encodedContent.type.typeId
36
+ assertEquals(contentType, " readReceipt " )
37
37
}
38
38
}
39
39
}
Original file line number Diff line number Diff line change 1
1
package org.xmtp.android.library.codecs
2
2
3
3
import com.google.protobuf.ByteString
4
- import org.xmtp.android.library.XMTPException
5
4
6
5
val ContentTypeReadReceipt = ContentTypeIdBuilder .builderFromAuthorityId(
7
6
" xmtp.org" ,
@@ -10,26 +9,20 @@ val ContentTypeReadReceipt = ContentTypeIdBuilder.builderFromAuthorityId(
10
9
versionMinor = 0
11
10
)
12
11
13
- data class ReadReceipt (
14
- // The timestamp the read receipt was sent, in ISO 8601 format
15
- val timestamp : String ,
16
- )
12
+ object ReadReceipt
17
13
18
14
data class ReadReceiptCodec (override var contentType : ContentTypeId = ContentTypeReadReceipt ) :
19
15
ContentCodec <ReadReceipt > {
20
16
21
17
override fun encode (content : ReadReceipt ): EncodedContent {
22
18
return EncodedContent .newBuilder().also {
23
19
it.type = ContentTypeReadReceipt
24
- it.putParameters(" timestamp" , content.timestamp)
25
20
it.content = ByteString .EMPTY
26
21
}.build()
27
22
}
28
23
29
24
override fun decode (content : EncodedContent ): ReadReceipt {
30
- val timestamp = content.parametersMap[" timestamp" ] ? : throw XMTPException (" Invalid Content" )
31
-
32
- return ReadReceipt (timestamp = timestamp)
25
+ return ReadReceipt
33
26
}
34
27
35
28
override fun fallback (content : ReadReceipt ): String? {
You can’t perform that action at this time.
0 commit comments