From 66334bdd537bc379f932be50a476c12e4b740805 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 27 Jul 2025 01:43:59 +0000 Subject: [PATCH] Move syncv3 typings event for user. Signed-off-by: Jason Volk --- src/api/client/sync/v3.rs | 24 +++++++++++++++++++----- src/service/rooms/typing/mod.rs | 15 --------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/api/client/sync/v3.rs b/src/api/client/sync/v3.rs index dd4062d1..2f97b888 100644 --- a/src/api/client/sync/v3.rs +++ b/src/api/client/sync/v3.rs @@ -26,9 +26,11 @@ use ruma::{ }, events::{ AnyRawAccountDataEvent, AnySyncEphemeralRoomEvent, StateEventType, + SyncEphemeralRoomEvent, TimelineEventType::*, presence::{PresenceEvent, PresenceEventContent}, room::member::{MembershipState, RoomMemberEventContent}, + typing::TypingEventContent, }, serde::Raw, uint, @@ -854,11 +856,7 @@ async fn load_joined_room( return Ok(Vec::>::new()); } - let typings = services - .rooms - .typing - .typings_event_for_user(room_id, sender_user) - .await?; + let typings = typings_event_for_user(services, room_id, sender_user).await?; Ok(vec![serde_json::from_str(&serde_json::to_string(&typings)?)?]) }) @@ -1203,3 +1201,19 @@ async fn fold_hero( heroes.push(user_id.to_owned()); heroes } + +async fn typings_event_for_user( + services: &Services, + room_id: &RoomId, + sender_user: &UserId, +) -> Result> { + Ok(SyncEphemeralRoomEvent { + content: TypingEventContent { + user_ids: services + .rooms + .typing + .typing_users_for_user(room_id, sender_user) + .await?, + }, + }) +} diff --git a/src/service/rooms/typing/mod.rs b/src/service/rooms/typing/mod.rs index 90f5b917..e7e5afa6 100644 --- a/src/service/rooms/typing/mod.rs +++ b/src/service/rooms/typing/mod.rs @@ -4,7 +4,6 @@ use futures::StreamExt; use ruma::{ OwnedRoomId, OwnedUserId, RoomId, UserId, api::federation::transactions::edu::{Edu, TypingContent}, - events::SyncEphemeralRoomEvent, }; use tokio::sync::{RwLock, broadcast}; use tuwunel_core::{ @@ -223,20 +222,6 @@ impl Service { Ok(user_ids) } - pub async fn typings_event_for_user( - &self, - room_id: &RoomId, - sender_user: &UserId, - ) -> Result> { - Ok(SyncEphemeralRoomEvent { - content: ruma::events::typing::TypingEventContent { - user_ids: self - .typing_users_for_user(room_id, sender_user) - .await?, - }, - }) - } - async fn federation_send(&self, room_id: &RoomId, user_id: &UserId, typing: bool) -> Result { debug_assert!( self.services.globals.user_is_local(user_id),