Commit e53abd2732

e53abd2732652290b28a39428bc6438ac3945e02

parent: 7a5291f65d

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-09-06 09:08 UTC

connection: Allow setting a transaction id when sending events.

Layout: unified · split

src/connection.rs +9 −1
@@ -98,10 +98,14 @@ impl Connection {
9898 ///
9999 /// * `content` - The content of the message that will be sent to the
100100 /// server.
101 ///
102 /// * `transaction_id` - Attach an unique id to this message, later on the
103 /// event will contain the same id in the unsigned part of the event.
101104 pub async fn send_message(
102105 &self,
103106 room_id: &RoomId,
104107 content: AnyMessageEventContent,
108 transaction_id: Option<Uuid>,
105109 ) -> MatrixResult<RoomSendResponse> {
106110 let room_id = room_id.to_owned();
107111 let client = self.client.clone();
@@ -110,7 +114,11 @@ impl Connection {
110114 .runtime
111115 .spawn(async move {
112116 client
113 .room_send(&room_id, content, Some(Uuid::new_v4()))
117 .room_send(
118 &room_id,
119 content,
120 Some(transaction_id.unwrap_or_else(Uuid::new_v4)),
121 )
114122 .await
115123 })
116124 .await;
src/room_buffer.rs +1 −1
@@ -119,7 +119,7 @@ impl BufferInputCallbackAsync for MatrixRoom {
119119
120120 let content = AnyMessageEventContent::RoomMessage(content);
121121
122 match c.send_message(&self.room_id, content).await {
122 match c.send_message(&self.room_id, content, None).await {
123123 Ok(_r) => (),
124124 Err(_e) => (),
125125 }