Skip to content

Commit

Permalink
remove timestamp from read receipt (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer authored Sep 15, 2023
1 parent 09c79ae commit 6c3546f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
15 changes: 2 additions & 13 deletions Sources/XMTP/Codecs/ReadReceiptCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import Foundation

public let ContentTypeReadReceipt = ContentTypeID(authorityID: "xmtp.org", typeID: "readReceipt", versionMajor: 1, versionMinor: 0)

public struct ReadReceipt {
public var timestamp: String

public init(timestamp: String) {
self.timestamp = timestamp
}
}
public struct ReadReceipt {}

public struct ReadReceiptCodec: ContentCodec {
public typealias T = ReadReceipt
Expand All @@ -28,18 +22,13 @@ public struct ReadReceiptCodec: ContentCodec {
var encodedContent = EncodedContent()

encodedContent.type = ContentTypeReadReceipt
encodedContent.parameters = ["timestamp": content.timestamp]
encodedContent.content = Data()

return encodedContent
}

public func decode(content: EncodedContent) throws -> ReadReceipt {
guard let timestamp = content.parameters["timestamp"] else {
throw CodecError.invalidContent
}

return ReadReceipt(timestamp: timestamp)
return ReadReceipt()
}

public func fallback(content: ReadReceipt) throws -> String? {
Expand Down
6 changes: 3 additions & 3 deletions Tests/XMTPTests/ReadReceiptTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ReadReceiptTests: XCTestCase {

try await conversation.send(text: "hey alice 2 bob")

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

try await conversation.send(
content: read,
Expand All @@ -30,7 +30,7 @@ class ReadReceiptTests: XCTestCase {
let updatedMessages = try await conversation.messages()

let message = try await conversation.messages()[0]
let content: ReadReceipt = try message.content()
XCTAssertEqual("2019-09-26T07:58:30.996+0200", content.timestamp)
let contentType: String = message.encodedContent.type.typeID
XCTAssertEqual("readReceipt", contentType)
}
}
2 changes: 1 addition & 1 deletion XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "XMTP"
spec.version = "0.5.4-alpha0"
spec.version = "0.5.6-alpha0"
spec.summary = "XMTP SDK Cocoapod"

# This description is used to generate tags and improve search results.
Expand Down

0 comments on commit 6c3546f

Please sign in to comment.