Merge branch 'master' into state-store
commit
6fcf0a86f9
|
@ -26,7 +26,7 @@ serde = "1.0.106"
|
||||||
serde_json = "1.0.51"
|
serde_json = "1.0.51"
|
||||||
|
|
||||||
# Ruma dependencies
|
# Ruma dependencies
|
||||||
js_int = "0.1.4"
|
js_int = "0.1.5"
|
||||||
ruma-api = "0.16.0-rc.2"
|
ruma-api = "0.16.0-rc.2"
|
||||||
ruma-client-api = { version = "0.8.0-rc.5" }
|
ruma-client-api = { version = "0.8.0-rc.5" }
|
||||||
ruma-events = { version = "0.21.0-beta.1" }
|
ruma-events = { version = "0.21.0-beta.1" }
|
||||||
|
|
|
@ -223,7 +223,7 @@ impl Client {
|
||||||
|
|
||||||
pub(crate) async fn calculate_room_names(&self) -> Vec<String> {
|
pub(crate) async fn calculate_room_names(&self) -> Vec<String> {
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
for (_id, room) in &self.joined_rooms {
|
for room in self.joined_rooms.values() {
|
||||||
let room = room.read().await;
|
let room = room.read().await;
|
||||||
res.push(room.room_name.calculate_name(&room.members))
|
res.push(room.room_name.calculate_name(&room.members))
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,13 +147,13 @@ impl RoomName {
|
||||||
} else if !self.aliases.is_empty() && !self.aliases[0].alias().is_empty() {
|
} else if !self.aliases.is_empty() && !self.aliases[0].alias().is_empty() {
|
||||||
self.aliases[0].alias().trim().to_string()
|
self.aliases[0].alias().trim().to_string()
|
||||||
} else {
|
} else {
|
||||||
let joined = self.joined_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_value());
|
let invited = self.invited_member_count.unwrap_or(UInt::MIN);
|
||||||
let heroes = UInt::new(self.heroes.len() as u64).unwrap();
|
let heroes = UInt::new(self.heroes.len() as u64).unwrap();
|
||||||
let one = UInt::new(1).unwrap();
|
let one = UInt::new(1).unwrap();
|
||||||
|
|
||||||
let invited_joined = if invited + joined == UInt::min_value() {
|
let invited_joined = if invited + joined == UInt::MIN {
|
||||||
UInt::min_value()
|
UInt::MIN
|
||||||
} else {
|
} else {
|
||||||
invited + joined - one
|
invited + joined - one
|
||||||
};
|
};
|
||||||
|
@ -166,8 +166,7 @@ impl RoomName {
|
||||||
.map(|mem| {
|
.map(|mem| {
|
||||||
mem.display_name
|
mem.display_name
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or(mem.user_id.localpart().to_string())
|
.unwrap_or_else(|| mem.user_id.localpart().to_string())
|
||||||
.to_string()
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
// stabilize ordering
|
// stabilize ordering
|
||||||
|
@ -180,7 +179,7 @@ impl RoomName {
|
||||||
.map(|mem| {
|
.map(|mem| {
|
||||||
mem.display_name
|
mem.display_name
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or(mem.user_id.localpart().to_string())
|
.unwrap_or_else(|| mem.user_id.localpart().to_string())
|
||||||
})
|
})
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
names.sort();
|
names.sort();
|
||||||
|
|
|
@ -327,17 +327,15 @@ mod test {
|
||||||
.invite_3pid(vec![])
|
.invite_3pid(vec![])
|
||||||
.is_direct(true)
|
.is_direct(true)
|
||||||
.power_level_override(PowerLevelsEventContent {
|
.power_level_override(PowerLevelsEventContent {
|
||||||
ban: Int::max_value(),
|
ban: Int::MAX,
|
||||||
events: BTreeMap::default(),
|
events: BTreeMap::default(),
|
||||||
events_default: Int::min_value(),
|
events_default: Int::MIN,
|
||||||
invite: Int::min_value(),
|
invite: Int::MIN,
|
||||||
kick: Int::min_value(),
|
kick: Int::MIN,
|
||||||
redact: Int::max_value(),
|
redact: Int::MAX,
|
||||||
state_default: Int::min_value(),
|
state_default: Int::MIN,
|
||||||
users_default: Int::min_value(),
|
users_default: Int::MIN,
|
||||||
notifications: NotificationPowerLevels {
|
notifications: NotificationPowerLevels { room: Int::MIN },
|
||||||
room: Int::min_value(),
|
|
||||||
},
|
|
||||||
users: BTreeMap::default(),
|
users: BTreeMap::default(),
|
||||||
})
|
})
|
||||||
.preset(RoomPreset::PrivateChat)
|
.preset(RoomPreset::PrivateChat)
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl EventBuilder {
|
||||||
variant: fn(Ev) -> Event,
|
variant: fn(Ev) -> Event,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let val = fs::read_to_string(path.as_ref())
|
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)
|
let event = serde_json::from_str::<EventJson<Ev>>(&val)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.deserialize()
|
.deserialize()
|
||||||
|
@ -112,7 +112,7 @@ impl EventBuilder {
|
||||||
variant: fn(Ev) -> Event,
|
variant: fn(Ev) -> Event,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let val = fs::read_to_string(path.as_ref())
|
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)
|
let event = serde_json::from_str::<EventJson<Ev>>(&val)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.deserialize()
|
.deserialize()
|
||||||
|
@ -128,7 +128,7 @@ impl EventBuilder {
|
||||||
variant: fn(Ev) -> RoomEvent,
|
variant: fn(Ev) -> RoomEvent,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let val = fs::read_to_string(path.as_ref())
|
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)
|
let event = serde_json::from_str::<EventJson<Ev>>(&val)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.deserialize()
|
.deserialize()
|
||||||
|
@ -144,7 +144,7 @@ impl EventBuilder {
|
||||||
variant: fn(Ev) -> StateEvent,
|
variant: fn(Ev) -> StateEvent,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let val = fs::read_to_string(path.as_ref())
|
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)
|
let event = serde_json::from_str::<EventJson<Ev>>(&val)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.deserialize()
|
.deserialize()
|
||||||
|
@ -156,7 +156,7 @@ impl EventBuilder {
|
||||||
/// Add a presence event to the presence events `Vec`.
|
/// Add a presence event to the presence events `Vec`.
|
||||||
pub fn add_presence_event_from_file<P: AsRef<Path>>(mut self, path: P) -> Self {
|
pub fn add_presence_event_from_file<P: AsRef<Path>>(mut self, path: P) -> Self {
|
||||||
let val = fs::read_to_string(path.as_ref())
|
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)
|
let event = serde_json::from_str::<EventJson<PresenceEvent>>(&val)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.deserialize()
|
.deserialize()
|
||||||
|
@ -174,7 +174,7 @@ impl EventBuilder {
|
||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let body = fs::read_to_string(path.as_ref())
|
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(
|
let mock = Some(
|
||||||
mock(method, matcher)
|
mock(method, matcher)
|
||||||
.with_status(200)
|
.with_status(200)
|
||||||
|
@ -367,12 +367,8 @@ impl ClientTestRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
for event in &self.room_events {
|
for event in &self.room_events {
|
||||||
cli.receive_joined_timeline_event(
|
cli.receive_joined_timeline_event(room_id, &mut EventJson::from(event), &mut false)
|
||||||
room_id,
|
.await;
|
||||||
&mut EventJson::from(event.clone()),
|
|
||||||
&mut false,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
for event in &self.presence_events {
|
for event in &self.presence_events {
|
||||||
cli.receive_presence_event(room_id, event).await;
|
cli.receive_presence_event(room_id, event).await;
|
||||||
|
|
Loading…
Reference in New Issue