Skip to content

Commit

Permalink
add should push entitlement
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jan 19, 2024
1 parent 8d3ccba commit 27cbb5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sources/XMTP/Codecs/ContentCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public protocol ContentCodec: Hashable, Equatable {
func encode(content: T, client: Client) throws -> EncodedContent
func decode(content: EncodedContent, client: Client) throws -> T
func fallback(content: T) throws -> String?
func shouldPush(content: T) throws -> Bool
}

public extension ContentCodec {
Expand Down
8 changes: 5 additions & 3 deletions Sources/XMTP/Messages/MessageV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ enum MessageV2Error: Error {
}

extension MessageV2 {
init(headerBytes: Data, ciphertext: CipherText) {
init(headerBytes: Data, ciphertext: CipherText, senderHmac: Data) {
self.init()
self.headerBytes = headerBytes
self.ciphertext = ciphertext
self.senderHmac = senderHmac
}

static func decrypt(_ id: String, _ topic: String, _ message: MessageV2, keyMaterial: Data, client: Client) throws -> DecryptedMessage {
Expand Down Expand Up @@ -78,7 +79,7 @@ extension MessageV2 {
}
}

static func encode(client: Client, content encodedContent: EncodedContent, topic: String, keyMaterial: Data) async throws -> MessageV2 {
static func encode(client: Client, content encodedContent: EncodedContent, topic: String, keyMaterial: Data, senderHmac: Data) async throws -> MessageV2 {
let payload = try encodedContent.serializedData()

let date = Date()
Expand All @@ -98,7 +99,8 @@ extension MessageV2 {

return MessageV2(
headerBytes: headerBytes,
ciphertext: ciphertext
ciphertext: ciphertext,
senderHmac: senderHmac
)
}
}

0 comments on commit 27cbb5a

Please sign in to comment.