Resolve stying review issues

This commit is contained in:
Devin R 2020-07-18 08:21:25 -04:00
parent 029c60be78
commit 75959cdc10
5 changed files with 59 additions and 31 deletions

View file

@ -31,7 +31,7 @@ impl Globals {
.unwrap_or("localhost")
.to_string()
.try_into()
.map_err(|_| crate::Error::bad_database("Private or public keys are invalid."))?,
.map_err(|_| Error::bad_database("Private or public keys are invalid."))?,
registration_disabled: config.get_bool("registration_disabled").unwrap_or(false),
})
}

View file

@ -1,6 +1,6 @@
use crate::{utils, Error, Result};
use ruma::{
events::{AnyEvent as EduEvent, EventJson},
events::{AnyEvent as EduEvent, EventJson, SyncEphemeralRoomEvent},
identifiers::{RoomId, UserId},
};
use std::convert::TryFrom;
@ -236,9 +236,41 @@ impl RoomEdus {
Ok(ruma::events::typing::TypingEvent {
content: ruma::events::typing::TypingEventContent { user_ids },
room_id: room_id.clone(), // Can be inferred
room_id: room_id.clone(),
})
}
// REMOVE the above method and uncomment the bottom when ruma/ruma PR #141 is merged
// pub fn roomactives_all(
// &self,
// room_id: &RoomId,
// ) -> Result<SyncEphemeralRoomEvent<ruma::events::typing::TypingEventContent>> {
// let mut prefix = room_id.to_string().as_bytes().to_vec();
// prefix.push(0xff);
// let mut user_ids = Vec::new();
// for user_id in self
// .roomactiveid_userid
// .scan_prefix(prefix)
// .values()
// .map(|user_id| {
// Ok::<_, Error>(
// UserId::try_from(utils::string_from_bytes(&user_id?).map_err(|_| {
// Error::bad_database("User ID in roomactiveid_userid is invalid unicode.")
// })?)
// .map_err(|_| {
// Error::bad_database("User ID in roomactiveid_userid is invalid.")
// })?,
// )
// })
// {
// user_ids.push(user_id?);
// }
// Ok(SyncEphemeralRoomEvent {
// content: ruma::events::typing::TypingEventContent { user_ids },
// })
// }
/// Sets a private read marker at `count`.
pub fn room_read_set(&self, room_id: &RoomId, user_id: &UserId, count: u64) -> Result<()> {