Skip to content
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

Remove timestamp from read receipts #157

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}
nplasterer marked this conversation as resolved.
Show resolved Hide resolved

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