Record room information (ID, name) in the database #48

Manually merged
projectmoon merged 10 commits from record-room-info into master 2020-11-30 20:16:01 +00:00
1 changed files with 10 additions and 0 deletions
Showing only changes of commit 118e4b00c7 - Show all commits

View File

@ -100,6 +100,16 @@ async fn record_room_information(
) -> Result<(), crate::db::errors::DataError> { ) -> Result<(), crate::db::errors::DataError> {
let room_id_str = room.room_id.as_str(); let room_id_str = room.room_id.as_str();
let usernames = matrix::get_users_in_room(&client, &room.room_id).await; 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 usernames
.into_iter() .into_iter()
.filter(|username| username != our_username) .filter(|username| username != our_username)