async_client: Allow the content and event type to be overridden when sending messages.

This commit is contained in:
Damir Jelić 2020-04-09 16:26:00 +02:00
parent dc2983d9a2
commit 01664bc613

View file

@ -180,6 +180,8 @@ impl SyncSettings {
}
}
#[cfg(feature = "encryption")]
use api::r0::client_exchange::send_event_to_device;
#[cfg(feature = "encryption")]
use api::r0::keys::{claim_keys, get_keys, upload_keys, KeyAlgorithm};
use api::r0::message::create_message_event;
@ -634,8 +636,10 @@ impl AsyncClient {
pub async fn room_send(
&mut self,
room_id: &RoomId,
data: MessageEventContent,
mut content: MessageEventContent,
) -> Result<create_message_event::Response> {
let mut event_type = EventType::RoomMessage;
#[cfg(feature = "encryption")]
{
let encrypted = {
@ -669,9 +673,9 @@ impl AsyncClient {
let request = create_message_event::Request {
room_id: room_id.clone(),
event_type: EventType::RoomMessage,
event_type,
txn_id: Uuid::new_v4().to_string(),
data,
data: content,
};
let response = self.send(request).await?;