Skip to content

Added Reactions to Message - #54

Open
kinga112 wants to merge 4 commits into
qntx:mainfrom
kinga112:add-reactions-to-decoded-message
Open

Added Reactions to Message#54
kinga112 wants to merge 4 commits into
qntx:mainfrom
kinga112:add-reactions-to-decoded-message

Conversation

@kinga112

@kinga112 kinga112 commented Aug 2, 2026

Copy link
Copy Markdown

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

…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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on Message and populate it from enriched-message FFI data.
  • Introduce FFI reaction structs/enums and add a reactions pointer 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_reactions should match the length of the exported reactions array. Using msg.reactions.len() can disagree with the allocated array length (because reactions_vec is built with filter_map). After computing num_reactions from reactions_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 thread xmtp/src/content.rs Outdated
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 thread xmtp/src/content.rs Outdated
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding ability to fetch reactions from conversation messages

3 participants