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 {
8888}
8989
9090#[derive(Clone)]
91pub struct MatrixRoom {
91struct MatrixRoom {
9292 homeserver: Rc<Url>,
9393 room_id: Rc<RoomId>,
9494
@@ -118,7 +118,11 @@ impl BufferInputCallbackAsync for MatrixRoom {
118118}
119119
120120impl 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 ) {
122126 if let Some(c) = &*self.connection.borrow() {
123127 // TODO check for errors and print them out.
124128 match c.send_message(&self.room_id, content, None).await {
@@ -244,6 +248,29 @@ impl RoomBuffer {
244248 }
245249 }
246250
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
247274 pub fn room_mut(&mut self) -> RefMut<'_, Room> {
248275 self.inner.room.borrow_mut()
249276 }
src/server.rs +1 −5
@@ -582,11 +582,7 @@ impl InnerServer {
582582
583583 let room_id = room.room_id.clone();
584584
585 let buffer = RoomBuffer::restore(
586 room,
587 &self.connection,
588 homeserver,
589 );
585 let buffer = RoomBuffer::restore(room, &self.connection, homeserver);
590586
591587 self.room_buffers.insert(room_id, buffer);
592588 }