Commit bcad95a38f

bcad95a38f289eab32290ea939e58b375f893e0b

parent: 054b4e2e78

Unsigned

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

weechat-matrix: Format the repo.

Layout: unified · split

src/room_buffer.rs +29 −2
@@ -88,7 +88,7 @@ pub enum RoomError {
88} 88}
89 89
90#[derive(Clone)] 90#[derive(Clone)]
91pub struct MatrixRoom { 91struct MatrixRoom {
92 homeserver: Rc<Url>, 92 homeserver: Rc<Url>,
93 room_id: Rc<RoomId>, 93 room_id: Rc<RoomId>,
94 94
@@ -118,7 +118,11 @@ impl BufferInputCallbackAsync for MatrixRoom {
118} 118}
119 119
120impl MatrixRoom { 120impl MatrixRoom {
121 pub async fn send_message(&self, buffer: BufferHandle, content: AnyMessageEventContent) { 121 pub async fn send_message(
122 &self,
123 buffer: BufferHandle,
124 content: AnyMessageEventContent,
125 ) {
122 if let Some(c) = &*self.connection.borrow() { 126 if let Some(c) = &*self.connection.borrow() {
123 // TODO check for errors and print them out. 127 // TODO check for errors and print them out.
124 match c.send_message(&self.room_id, content, None).await { 128 match c.send_message(&self.room_id, content, None).await {
@@ -244,6 +248,29 @@ impl RoomBuffer {
244 } 248 }
245 } 249 }
246 250
251 /// Send the given content to the server.
252 ///
253 /// # Arguments
254 ///
255 /// * `content` - The content that should be sent to the server.
256 ///
257 /// # Examples
258 ///
259 /// ```
260 /// let content = MessageEventContent::Text(TextMessageEventContent {
261 /// body: "Hello world".to_owned(),
262 /// formatted: None,
263 /// relates_to: None,
264 /// });
265 /// let content = AnyMessageEventContent::RoomMessage(content);
266 ///
267 /// buffer.send_message(content).await
268 /// ```
269 pub async fn send_message(&self, content: AnyMessageEventContent) {
270 let buffer = self.buffer_handle.clone();
271 self.inner.send_message(buffer, content).await
272 }
273
247 pub fn room_mut(&mut self) -> RefMut<'_, Room> { 274 pub fn room_mut(&mut self) -> RefMut<'_, Room> {
248 self.inner.room.borrow_mut() 275 self.inner.room.borrow_mut()
249 } 276 }
src/server.rs +1 −5
@@ -582,11 +582,7 @@ impl InnerServer {
582 582
583 let room_id = room.room_id.clone(); 583 let room_id = room.room_id.clone();
584 584
585 let buffer = RoomBuffer::restore( 585 let buffer = RoomBuffer::restore(room, &self.connection, homeserver);
586 room,
587 &self.connection,
588 homeserver,
589 );
590 586
591 self.room_buffers.insert(room_id, buffer); 587 self.room_buffers.insert(room_id, buffer);
592 } 588 }