-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dm validation fix; upstream changes (#461)
* dm validation fix. upstream changes * adds proto rust reaction and message with reactions func * bump podspec --------- Co-authored-by: cameronvoell <[email protected]>
- Loading branch information
1 parent
52f80ac
commit f4c7336
Showing
16 changed files
with
479 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// ReactionCodec.swift | ||
// | ||
// | ||
// Created by Naomi Plasterer on 7/26/23. | ||
// | ||
|
||
import Foundation | ||
import LibXMTP | ||
|
||
public let ContentTypeReactionV2 = ContentTypeID(authorityID: "xmtp.org", typeID: "reaction", versionMajor: 2, versionMinor: 0) | ||
|
||
public struct ReactionV2Codec: ContentCodec { | ||
public typealias T = FfiReaction | ||
public var contentType = ContentTypeReactionV2 | ||
|
||
public init() {} | ||
|
||
public func encode(content: FfiReaction) throws -> EncodedContent { | ||
return try EncodedContent(serializedBytes: encodeReaction(reaction: content)) | ||
} | ||
|
||
public func decode(content: EncodedContent) throws -> FfiReaction { | ||
try decodeReaction(bytes: content.serializedBytes()) | ||
} | ||
|
||
public func fallback(content: FfiReaction) throws -> String? { | ||
switch content.action { | ||
case .added: | ||
return "Reacted “\(content.content)” to an earlier message" | ||
case .removed: | ||
return "Removed “\(content.content)” from an earlier message" | ||
case .unknown: | ||
return nil | ||
} | ||
} | ||
|
||
public func shouldPush(content: FfiReaction) throws -> Bool { | ||
switch content.action { | ||
case .added: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.