-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test json deserialization of reaction in rust
- Loading branch information
1 parent
b9f90f1
commit d150b91
Showing
15 changed files
with
304 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Version: 13846991 | ||
Branch: cv/01-02-save_parent_id_to_db_and_add_get_group_messages_with_reactions_function | ||
Date: 2025-01-07 17:52:41 +0000 | ||
Version: 76983ce7 | ||
Branch: cv/01-10-json_deserialization_for_legacy_reactions | ||
Date: 2025-01-11 00:19:35 +0000 |
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
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
42 changes: 42 additions & 0 deletions
42
library/src/main/java/org/xmtp/android/library/codecs/ReactionV2Codec.kt
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,42 @@ | ||
package uniffi.xmtpv3.org.xmtp.android.library.codecs | ||
|
||
import org.xmtp.android.library.codecs.ContentCodec | ||
import org.xmtp.android.library.codecs.ContentTypeId | ||
import org.xmtp.android.library.codecs.ContentTypeIdBuilder | ||
import org.xmtp.android.library.codecs.EncodedContent | ||
import uniffi.xmtpv3.FfiReaction | ||
import uniffi.xmtpv3.FfiReactionAction | ||
import uniffi.xmtpv3.decodeReaction | ||
import uniffi.xmtpv3.encodeReaction | ||
|
||
val ContentTypeReactionV2 = ContentTypeIdBuilder.builderFromAuthorityId( | ||
"xmtp.org", | ||
"reaction", | ||
versionMajor = 2, | ||
versionMinor = 0, | ||
) | ||
|
||
data class ReactionV2Codec(override var contentType: ContentTypeId = ContentTypeReactionV2) : | ||
ContentCodec<FfiReaction> { | ||
|
||
override fun encode(content: FfiReaction): EncodedContent { | ||
return EncodedContent.parseFrom(encodeReaction(content)) | ||
} | ||
|
||
override fun decode(content: EncodedContent): FfiReaction { | ||
return decodeReaction(content.toByteArray()) | ||
} | ||
|
||
override fun fallback(content: FfiReaction): String? { | ||
return when (content.action) { | ||
FfiReactionAction.ADDED -> "Reacted “${content.content}” to an earlier message" | ||
FfiReactionAction.REMOVED -> "Removed “${content.content}” from an earlier message" | ||
else -> null | ||
} | ||
} | ||
|
||
override fun shouldPush(content: FfiReaction): Boolean = when (content.action) { | ||
FfiReactionAction.ADDED -> true | ||
else -> 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
Oops, something went wrong.