From 118e4b00c7a6de39404f8b441381151cb4c58cf7 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sun, 29 Nov 2020 17:06:04 +0000 Subject: [PATCH] Store room info when joining a room. --- src/bot/event_handlers.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bot/event_handlers.rs b/src/bot/event_handlers.rs index 3792916..1b71cd6 100644 --- a/src/bot/event_handlers.rs +++ b/src/bot/event_handlers.rs @@ -100,6 +100,16 @@ async fn record_room_information( ) -> Result<(), crate::db::errors::DataError> { let room_id_str = room.room_id.as_str(); let usernames = matrix::get_users_in_room(&client, &room.room_id).await; + + let info = crate::models::RoomInfo { + room_id: room_id_str.to_owned(), + room_name: room.display_name(), + }; + + // TODO this and the username adding should be one whole + // transaction in the db. + db.rooms.insert_room_info(&info)?; + usernames .into_iter() .filter(|username| username != our_username)