mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 11:05:32 -04:00
feat(bindings): Add sending of reactions to matrix-sdk-ffi
This commit is contained in:
committed by
Jonas Platte
parent
a18919bf50
commit
6a386ca5fb
@@ -203,7 +203,7 @@ dictionary Session {
|
||||
interface Room {
|
||||
[Throws=ClientError]
|
||||
string display_name();
|
||||
|
||||
|
||||
[Throws=ClientError]
|
||||
boolean is_encrypted();
|
||||
|
||||
@@ -232,6 +232,9 @@ interface Room {
|
||||
|
||||
[Throws=ClientError]
|
||||
void redact(string event_id, string? reason, string? txn_id);
|
||||
|
||||
[Throws=ClientError]
|
||||
void send_reaction(string event_id, string key);
|
||||
};
|
||||
|
||||
callback interface TimelineListener {
|
||||
|
||||
@@ -12,7 +12,8 @@ use matrix_sdk::{
|
||||
},
|
||||
ruma::{
|
||||
events::{
|
||||
relation::Replacement,
|
||||
reaction::ReactionEventContent,
|
||||
relation::{Annotation, Replacement},
|
||||
room::message::{
|
||||
ForwardThread, MessageType, Relation, RoomMessageEvent, RoomMessageEventContent,
|
||||
},
|
||||
@@ -281,6 +282,19 @@ impl Room {
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_reaction(&self, event_id: String, key: String) -> Result<()> {
|
||||
let room = match &self.room {
|
||||
SdkRoom::Joined(j) => j.clone(),
|
||||
_ => bail!("Can't send reaction in a room that isn't in joined state"),
|
||||
};
|
||||
|
||||
RUNTIME.block_on(async move {
|
||||
let event_id = EventId::parse(event_id)?;
|
||||
room.send(ReactionEventContent::new(Annotation::new(event_id, key)), None).await?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for Room {
|
||||
|
||||
Reference in New Issue
Block a user