room/ev_emitter: add tombstone to emitted events
This commit is contained in:
parent
ef4d69b0ac
commit
07053cfe26
4 changed files with 24 additions and 4 deletions
|
@ -637,6 +637,13 @@ impl Client {
|
|||
}
|
||||
}
|
||||
}
|
||||
RoomEvent::RoomTombstone(tomb) => {
|
||||
if let Some(ee) = &self.event_emitter {
|
||||
if let Some(room) = self.get_room(&room_id) {
|
||||
ee.on_room_tombstone(Arc::clone(&room), &tomb).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -693,6 +700,13 @@ impl Client {
|
|||
}
|
||||
}
|
||||
}
|
||||
StateEvent::RoomTombstone(tomb) => {
|
||||
if let Some(ee) = &self.event_emitter {
|
||||
if let Some(room) = self.get_room(&room_id) {
|
||||
ee.on_room_tombstone(Arc::clone(&room), &tomb).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ use crate::events::{
|
|||
name::NameEvent,
|
||||
power_levels::PowerLevelsEvent,
|
||||
redaction::RedactionEvent,
|
||||
tombstone::TombstoneEvent,
|
||||
},
|
||||
};
|
||||
use crate::models::Room;
|
||||
|
@ -98,6 +99,8 @@ pub trait EventEmitter: Send + Sync {
|
|||
async fn on_room_redaction(&self, _: Arc<RwLock<Room>>, _: &RedactionEvent) {}
|
||||
/// Fires when `AsyncClient` receives a `RoomEvent::RoomPowerLevels` event.
|
||||
async fn on_room_power_levels(&self, _: Arc<RwLock<Room>>, _: &PowerLevelsEvent) {}
|
||||
/// Fires when `AsyncClient` receives a `RoomEvent::Tombstone` event.
|
||||
async fn on_room_tombstone(&self, _: Arc<RwLock<Room>>, _: &TombstoneEvent) {}
|
||||
|
||||
// `RoomEvent`s from `IncomingState`
|
||||
/// Fires when `AsyncClient` receives a `StateEvent::RoomMember` event.
|
||||
|
@ -167,6 +170,9 @@ mod test {
|
|||
async fn on_room_power_levels(&self, _: Arc<RwLock<Room>>, _: &PowerLevelsEvent) {
|
||||
self.0.lock().await.push("power".to_string())
|
||||
}
|
||||
async fn on_room_tombstone(&self, _: Arc<RwLock<Room>>, _: &TombstoneEvent) {
|
||||
self.0.lock().await.push("tombstone".to_string())
|
||||
}
|
||||
|
||||
async fn on_state_member(&self, _: Arc<RwLock<Room>>, _: &MemberEvent) {
|
||||
self.0.lock().await.push("state member".to_string())
|
||||
|
|
|
@ -165,6 +165,7 @@ impl RoomName {
|
|||
.take(3)
|
||||
.map(|mem| mem.user_id.localpart().to_string())
|
||||
.collect::<Vec<String>>();
|
||||
// stabilize ordering
|
||||
names.sort();
|
||||
names.join(", ")
|
||||
} else if heroes < invited_joined && invited + joined > one {
|
||||
|
|
|
@ -290,7 +290,7 @@ impl Into<get_message_events::Request> for MessagesRequestBuilder {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use super::*;
|
||||
use crate::events::room::power_levels::NotificationPowerLevels;
|
||||
|
@ -371,9 +371,8 @@ mod test {
|
|||
.from("t47429-4392820_219380_26003_2265".to_string())
|
||||
.to("t4357353_219380_26003_2265".to_string())
|
||||
.direction(Direction::Backward)
|
||||
.limit(UInt::new(10).unwrap());
|
||||
// TODO this makes ruma error `Err(IntoHttp(IntoHttpError(Query(Custom("unsupported value")))))`??
|
||||
// .filter(RoomEventFilter::default());
|
||||
.limit(UInt::new(10).unwrap())
|
||||
.filter(RoomEventFilter::default());
|
||||
|
||||
let cli = AsyncClient::new(homeserver, Some(session)).unwrap();
|
||||
assert!(cli.room_messages(builder).await.is_ok());
|
||||
|
|
Loading…
Reference in a new issue