Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reaction codec libxmtp integration #1345

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

cameronvoell
Copy link
Contributor

@cameronvoell cameronvoell commented Nov 26, 2024

Demonstrates XIP-38: Queryable Content Fields (naming still in progress )

See new rust bindings function and test below:

#[derive(uniffi::Record)]
pub struct FfiMessageWithReactions {
    pub message: FfiMessage,
    pub reactions: Vec<FfiMessage>,
}

pub async fn find_messages_with_reactions(
        &self,
        opts: FfiListMessagesOptions,
    ) -> Result<Vec<FfiMessageWithReactions>, GenericError> {
        let delivery_status = opts.delivery_status.map(|status| status.into());
        let direction = opts.direction.map(|dir| dir.into());
        let kind = match self.conversation_type()? {
            FfiConversationType::Group => None,
            FfiConversationType::Dm => Some(GroupMessageKind::Application),
            FfiConversationType::Sync => None,
        };

        let messages: Vec<FfiMessageWithReactions> = self
            .inner
            .find_messages_with_reactions(
                &MsgQueryArgs::default()
                    .maybe_sent_before_ns(opts.sent_before_ns)
                    .maybe_sent_after_ns(opts.sent_after_ns)
                    .maybe_kind(kind)
                    .maybe_delivery_status(delivery_status)
                    .maybe_limit(opts.limit)
                    .maybe_direction(direction),
            )?
            .into_iter()
            .map(|msg| msg.into())
            .collect();
        Ok(messages)
    }

Test code: https://github.com/xmtp/libxmtp/pull/1345/files#diff-3a24c3e76565487a710ac9863ac05160128f4f90892e07849b555a6de43a6e8fR4495-R4591

@insipx
Copy link
Contributor

insipx commented Nov 26, 2024

I like the direction of these content types, seems like a natural progression to introduce them as another crate library

Looking over this stuff, the only thing I find off is to introduce migrations and call into xmtp_mls just for database operations. WDYT about splitting the store stuff into its own crate, xmtp_db or something like that? Maybe its out of scope for this XIP/feature, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants