mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 23:15:08 -04:00
Update signature of AppService::register_event_handler
It no longer requires a mutable `AppService` and can also be chained, like `Client::register_event_handler`.
This commit is contained in:
@@ -39,7 +39,7 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let server_name = "localhost";
|
||||
let registration = AppServiceRegistration::try_from_yaml_file("./tests/registration.yaml")?;
|
||||
|
||||
let mut appservice = AppService::new(homeserver_url, server_name, registration).await?;
|
||||
let appservice = AppService::new(homeserver_url, server_name, registration).await?;
|
||||
appservice
|
||||
.register_event_handler({
|
||||
let appservice = appservice.clone();
|
||||
|
||||
@@ -380,7 +380,7 @@ impl AppService {
|
||||
///
|
||||
/// [`join` room `timeline` events]: https://spec.matrix.org/unstable/client-server-api/#get_matrixclientr0sync
|
||||
/// [MSC2409]: https://github.com/matrix-org/matrix-doc/pull/2409
|
||||
pub async fn register_event_handler<Ev, Ctx, H>(&mut self, handler: H) -> Result<()>
|
||||
pub async fn register_event_handler<Ev, Ctx, H>(&self, handler: H) -> Result<&Self>
|
||||
where
|
||||
Ev: SyncEvent + DeserializeOwned + Send + 'static,
|
||||
H: EventHandler<Ev, Ctx>,
|
||||
@@ -389,7 +389,7 @@ impl AppService {
|
||||
let client = self.get_cached_client(None)?;
|
||||
client.register_event_handler(handler).await;
|
||||
|
||||
Ok(())
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Register a responder for queries about the existence of a user with a
|
||||
|
||||
@@ -199,7 +199,7 @@ async fn test_no_access_token() -> Result<()> {
|
||||
|
||||
#[async_test]
|
||||
async fn test_event_handler() -> Result<()> {
|
||||
let mut appservice = appservice(None).await?;
|
||||
let appservice = appservice(None).await?;
|
||||
|
||||
#[allow(clippy::mutex_atomic)]
|
||||
let on_state_member = Arc::new(Mutex::new(false));
|
||||
|
||||
Reference in New Issue
Block a user