Added Reactions to Message - #54
Open
kinga112 wants to merge 4 commits into
Open
Conversation
…es takes a list of DecodedMessage in the official XMTP lib, but not sure if that 1 to 1 match can be applied here. This is the solution I found viable. Setting sender_inbox_id on send_reaction is always an empty string, but on getter, it gets populated with the DecodedMessageMetadata sender_inbox_id.
gitctrlx
requested review from
Copilot and
gitctrlx
and removed request for
gitctrlx
August 3, 2026 02:41
This was
linked to
issues
Aug 3, 2026
There was a problem hiding this comment.
Pull request overview
This PR adds first-class reaction data to enriched conversation messages in the Rust SDK/FFI layer, including extending reaction types with sender_inbox_id and plumbing a reactions array through the C FFI surface.
Changes:
- Expose a
reactions: Vec<Reaction>field onMessageand populate it from enriched-message FFI data. - Introduce FFI reaction structs/enums and add a
reactionspointer to the enriched-message FFI struct. - Extend reaction content/types to include
sender_inbox_id.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| xmtp/src/ffi.rs | Adds an FFI helper to convert a raw reactions array into safe SDK Reaction values. |
| xmtp/src/conversation.rs | Adds Message.reactions and wires reaction decoding from the enriched-message FFI struct. |
| xmtp/src/content.rs | Extends reaction types (incl. protobuf + FFI conversion) to include sender_inbox_id. |
| xmtp-sys/src/bindings.rs | Updates generated bindings to include reaction structs/enums and enriched-message reactions pointer. |
| xmtp-ffi/src/ffi.rs | Defines the C-facing FFI reaction types and adds reactions to FfiEnrichedMessage. |
| xmtp-ffi/src/conversation.rs | Constructs the reactions array when converting decoded messages to enriched FFI messages. |
| xmtp-ffi/include/xmtp_ffi.h | Exposes reaction enums/structs and the enriched-message reactions pointer in the C header. |
Suppressed comments (1)
xmtp-ffi/src/conversation.rs:1593
num_reactionsshould match the length of the exportedreactionsarray. Usingmsg.reactions.len()can disagree with the allocated array length (becausereactions_vecis built withfilter_map). After computingnum_reactionsfromreactions_vec.len(), use that variable here.
expires_at_ns: msg.metadata.expires_at_ns.unwrap_or(0),
reactions,
num_reactions: msg.reactions.len() as i32,
num_replies: msg.num_replies as i32,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+73
to
+77
| /// Inbox ID of the reaction sender. | ||
| #[prost(string, tag = "3")] | ||
| pub sender_inbox_id: String, | ||
| /// Reaction action. | ||
| #[prost(enumeration = "ReactionAction", tag = "3")] | ||
| #[prost(enumeration = "ReactionAction", tag = "4")] |
Comment on lines
+337
to
+353
| pub(crate) fn from_ffi(ffi: &XmtpFfiReaction) -> Self { | ||
| Self { | ||
| // SAFETY: `reference` is a C string allocated by the FFI layer (or null, handled by `take_c_string`). | ||
| reference: unsafe { take_c_string(ffi.reference) }.unwrap_or_default(), | ||
| // SAFETY: `reference_inbox_id` is a C string allocated by the FFI layer (or null, handled by `take_c_string`). | ||
| reference_inbox_id: unsafe { take_c_string(ffi.reference_inbox_id) } | ||
| .unwrap_or_default(), | ||
| // SAFETY: `sender_inbox_id` is a C string allocated by the FFI layer (or null, handled by `take_c_string`). | ||
| sender_inbox_id: unsafe { take_c_string(ffi.sender_inbox_id) }.unwrap_or_default(), | ||
| action: ReactionAction::from_ffi(ffi.action as i32) | ||
| .unwrap_or(ReactionAction::Unspecified), | ||
| // SAFETY: `content` is a C string allocated by the FFI layer (or null, handled by `take_c_string`). | ||
| content: unsafe { take_c_string(ffi.content) }.unwrap_or_default(), | ||
| schema: ReactionSchema::from_ffi(ffi.schema as i32) | ||
| .unwrap_or(ReactionSchema::Unspecified), | ||
| } | ||
| } |
Comment on lines
+1561
to
+1565
| let reactions = if reactions_vec.is_empty() { | ||
| std::ptr::null_mut() | ||
| } else { | ||
| Box::into_raw(reactions_vec.into_boxed_slice()) as *mut FfiReaction | ||
| }; |
Comment on lines
+1561
to
+1564
| let reactions = if reactions_vec.is_empty() { | ||
| std::ptr::null_mut() | ||
| } else { | ||
| Box::into_raw(reactions_vec.into_boxed_slice()) as *mut FfiReaction |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added links to Reaction and then eventually added sender_inbox_id to Reaction types. Reactions property in Messages takes a list of DecodedMessage in the official XMTP lib, but not sure if that 1 to 1 match can be applied here. This is the solution I found viable. Setting sender_inbox_id on send_reaction is always an empty string, but on getter, it gets populated with the DecodedMessageMetadata sender_inbox_id.
Changes
Adds the changes to implement #10