Skip to content

Commit

Permalink
feat(ffi): Expose the method to send custom events with JSON content (#…
Browse files Browse the repository at this point in the history
…4390)

This patch adds the Room::send_raw method to the bindings, making it usable from
e.g. Swift.

Signed-off-by: Jonas Richard Richter <[email protected]>
  • Loading branch information
jonasrichardrichter authored and andybalaam committed Dec 18, 2024
1 parent 08e6612 commit 8d829ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions bindings/matrix-sdk-ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Additions:

- Add `Encryption::get_user_identity` which returns `UserIdentity`
- Add `ClientBuilder::room_key_recipient_strategy`
- Add `Room::send_raw`
16 changes: 16 additions & 0 deletions bindings/matrix-sdk-ffi/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,22 @@ impl Room {
Ok(())
}

/// Send a raw event to the room.
///
/// # Arguments
///
/// * `event_type` - The type of the event to send.
///
/// * `content` - The content of the event to send encoded as JSON string.
pub async fn send_raw(&self, event_type: String, content: String) -> Result<(), ClientError> {
let content_json: serde_json::Value = serde_json::from_str(&content)
.map_err(|e| ClientError::Generic { msg: format!("Failed to parse JSON: {e}") })?;

self.inner.send_raw(&event_type, content_json).await?;

Ok(())
}

/// Redacts an event from the room.
///
/// # Arguments
Expand Down

0 comments on commit 8d829ff

Please sign in to comment.