Merge branch 'master' into state-store

master
Devin R 2020-04-27 07:20:21 -04:00
commit 6fcf0a86f9
5 changed files with 24 additions and 31 deletions

View File

@ -26,7 +26,7 @@ serde = "1.0.106"
serde_json = "1.0.51"
# Ruma dependencies
js_int = "0.1.4"
js_int = "0.1.5"
ruma-api = "0.16.0-rc.2"
ruma-client-api = { version = "0.8.0-rc.5" }
ruma-events = { version = "0.21.0-beta.1" }

View File

@ -223,7 +223,7 @@ impl Client {
pub(crate) async fn calculate_room_names(&self) -> Vec<String> {
let mut res = Vec::new();
for (_id, room) in &self.joined_rooms {
for room in self.joined_rooms.values() {
let room = room.read().await;
res.push(room.room_name.calculate_name(&room.members))
}

View File

@ -147,13 +147,13 @@ impl RoomName {
} else if !self.aliases.is_empty() && !self.aliases[0].alias().is_empty() {
self.aliases[0].alias().trim().to_string()
} else {
let joined = self.joined_member_count.unwrap_or(UInt::min_value());
let invited = self.invited_member_count.unwrap_or(UInt::min_value());
let joined = self.joined_member_count.unwrap_or(UInt::MIN);
let invited = self.invited_member_count.unwrap_or(UInt::MIN);
let heroes = UInt::new(self.heroes.len() as u64).unwrap();
let one = UInt::new(1).unwrap();
let invited_joined = if invited + joined == UInt::min_value() {
UInt::min_value()
let invited_joined = if invited + joined == UInt::MIN {
UInt::MIN
} else {
invited + joined - one
};
@ -166,8 +166,7 @@ impl RoomName {
.map(|mem| {
mem.display_name
.clone()
.unwrap_or(mem.user_id.localpart().to_string())
.to_string()
.unwrap_or_else(|| mem.user_id.localpart().to_string())
})
.collect::<Vec<String>>();
// stabilize ordering
@ -180,7 +179,7 @@ impl RoomName {
.map(|mem| {
mem.display_name
.clone()
.unwrap_or(mem.user_id.localpart().to_string())
.unwrap_or_else(|| mem.user_id.localpart().to_string())
})
.collect::<Vec<String>>();
names.sort();

View File

@ -327,17 +327,15 @@ mod test {
.invite_3pid(vec![])
.is_direct(true)
.power_level_override(PowerLevelsEventContent {
ban: Int::max_value(),
ban: Int::MAX,
events: BTreeMap::default(),
events_default: Int::min_value(),
invite: Int::min_value(),
kick: Int::min_value(),
redact: Int::max_value(),
state_default: Int::min_value(),
users_default: Int::min_value(),
notifications: NotificationPowerLevels {
room: Int::min_value(),
},
events_default: Int::MIN,
invite: Int::MIN,
kick: Int::MIN,
redact: Int::MAX,
state_default: Int::MIN,
users_default: Int::MIN,
notifications: NotificationPowerLevels { room: Int::MIN },
users: BTreeMap::default(),
})
.preset(RoomPreset::PrivateChat)

View File

@ -96,7 +96,7 @@ impl EventBuilder {
variant: fn(Ev) -> Event,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -112,7 +112,7 @@ impl EventBuilder {
variant: fn(Ev) -> Event,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -128,7 +128,7 @@ impl EventBuilder {
variant: fn(Ev) -> RoomEvent,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -144,7 +144,7 @@ impl EventBuilder {
variant: fn(Ev) -> StateEvent,
) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<Ev>>(&val)
.unwrap()
.deserialize()
@ -156,7 +156,7 @@ impl EventBuilder {
/// Add a presence event to the presence events `Vec`.
pub fn add_presence_event_from_file<P: AsRef<Path>>(mut self, path: P) -> Self {
let val = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let event = serde_json::from_str::<EventJson<PresenceEvent>>(&val)
.unwrap()
.deserialize()
@ -174,7 +174,7 @@ impl EventBuilder {
P: AsRef<Path>,
{
let body = fs::read_to_string(path.as_ref())
.expect(&format!("file not found {:?}", path.as_ref()));
.unwrap_or_else(|_| panic!("file not found {:?}", path.as_ref()));
let mock = Some(
mock(method, matcher)
.with_status(200)
@ -367,12 +367,8 @@ impl ClientTestRunner {
}
for event in &self.room_events {
cli.receive_joined_timeline_event(
room_id,
&mut EventJson::from(event.clone()),
&mut false,
)
.await;
cli.receive_joined_timeline_event(room_id, &mut EventJson::from(event), &mut false)
.await;
}
for event in &self.presence_events {
cli.receive_presence_event(room_id, event).await;