diff --git a/src/api/client_server/sync.rs b/src/api/client_server/sync.rs index 974cb1d5..24b1b596 100644 --- a/src/api/client_server/sync.rs +++ b/src/api/client_server/sync.rs @@ -1003,16 +1003,10 @@ async fn load_joined_room( .map(|(_, _, v)| v) .collect(); - if services() - .rooms - .edus - .typing - .last_typing_update(room_id) - .await? > since - { + if services().rooms.typing.last_typing_update(room_id).await? > since { edus.push( serde_json::from_str( - &serde_json::to_string(&services().rooms.edus.typing.typings_all(room_id).await?) + &serde_json::to_string(&services().rooms.typing.typings_all(room_id).await?) .expect("event is valid, we just created it"), ) .expect("event is valid, we just created it"), diff --git a/src/api/client_server/typing.rs b/src/api/client_server/typing.rs index 40510b88..ee310ad8 100644 --- a/src/api/client_server/typing.rs +++ b/src/api/client_server/typing.rs @@ -28,14 +28,12 @@ pub async fn create_typing_event_route( ); services() .rooms - .edus .typing .typing_add(sender_user, &body.room_id, utils::millis_since_unix_epoch() + duration) .await?; } else { services() .rooms - .edus .typing .typing_remove(sender_user, &body.room_id) .await?; diff --git a/src/api/server_server.rs b/src/api/server_server.rs index b8ccebbe..5f78e18a 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -410,14 +410,12 @@ pub async fn send_transaction_message_route( + services().globals.config.typing_federation_timeout_s * 1000; services() .rooms - .edus .typing .typing_add(&typing.user_id, &typing.room_id, timeout) .await?; } else { services() .rooms - .edus .typing .typing_remove(&typing.user_id, &typing.room_id) .await?; diff --git a/src/database/key_value/globals.rs b/src/database/key_value/globals.rs index 246767bc..1c1f4938 100644 --- a/src/database/key_value/globals.rs +++ b/src/database/key_value/globals.rs @@ -97,7 +97,7 @@ impl service::globals::Data for KeyValueDatabase { // EDUs futures.push(Box::pin(async move { - let _result = services().rooms.edus.typing.wait_for_update(&room_id).await; + let _result = services().rooms.typing.wait_for_update(&room_id).await; })); futures.push(self.readreceiptid_readreceipt.watch_prefix(&roomid_prefix)); diff --git a/src/service/mod.rs b/src/service/mod.rs index 5fd0492f..cc5d4660 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -73,11 +73,6 @@ impl Services<'_> { presence: rooms::edus::presence::Service { db, }, - typing: rooms::edus::typing::Service { - typing: RwLock::new(BTreeMap::new()), - last_typing_update: RwLock::new(BTreeMap::new()), - typing_update_sender: broadcast::channel(100).0, - }, }, event_handler: rooms::event_handler::Service, lazy_loading: rooms::lazy_loading::Service { @@ -130,6 +125,11 @@ impl Services<'_> { threads: rooms::threads::Service { db, }, + typing: rooms::typing::Service { + typing: RwLock::new(BTreeMap::new()), + last_typing_update: RwLock::new(BTreeMap::new()), + typing_update_sender: broadcast::channel(100).0, + }, spaces: rooms::spaces::Service { roomid_spacehierarchy_cache: Mutex::new(LruCache::new( (100.0 * config.conduit_cache_capacity_modifier) as usize, diff --git a/src/service/rooms/edus/mod.rs b/src/service/rooms/edus/mod.rs index e73d5bb8..5626065d 100644 --- a/src/service/rooms/edus/mod.rs +++ b/src/service/rooms/edus/mod.rs @@ -1,9 +1,7 @@ pub mod presence; -pub mod typing; pub trait Data: presence::Data + 'static {} pub struct Service { pub presence: presence::Service, - pub typing: typing::Service, } diff --git a/src/service/rooms/mod.rs b/src/service/rooms/mod.rs index 8dec1e9e..63eb7da6 100644 --- a/src/service/rooms/mod.rs +++ b/src/service/rooms/mod.rs @@ -17,6 +17,7 @@ pub mod state_cache; pub mod state_compressor; pub mod threads; pub mod timeline; +pub mod typing; pub mod user; pub trait Data: @@ -60,6 +61,7 @@ pub struct Service { pub state_compressor: state_compressor::Service, pub timeline: timeline::Service, pub threads: threads::Service, + pub typing: typing::Service, pub spaces: spaces::Service, pub user: user::Service, } diff --git a/src/service/rooms/edus/typing/mod.rs b/src/service/rooms/typing/mod.rs similarity index 100% rename from src/service/rooms/edus/typing/mod.rs rename to src/service/rooms/typing/mod.rs