move typing feature up one level out of rooms.edus.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
89a919ce75
commit
9790477b0e
8 changed files with 10 additions and 20 deletions
|
@ -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"),
|
||||
|
|
|
@ -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?;
|
||||
|
|
|
@ -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?;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue