Move syncv3 typings event for user.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -26,9 +26,11 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
events::{
|
events::{
|
||||||
AnyRawAccountDataEvent, AnySyncEphemeralRoomEvent, StateEventType,
|
AnyRawAccountDataEvent, AnySyncEphemeralRoomEvent, StateEventType,
|
||||||
|
SyncEphemeralRoomEvent,
|
||||||
TimelineEventType::*,
|
TimelineEventType::*,
|
||||||
presence::{PresenceEvent, PresenceEventContent},
|
presence::{PresenceEvent, PresenceEventContent},
|
||||||
room::member::{MembershipState, RoomMemberEventContent},
|
room::member::{MembershipState, RoomMemberEventContent},
|
||||||
|
typing::TypingEventContent,
|
||||||
},
|
},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
uint,
|
uint,
|
||||||
@@ -854,11 +856,7 @@ async fn load_joined_room(
|
|||||||
return Ok(Vec::<Raw<AnySyncEphemeralRoomEvent>>::new());
|
return Ok(Vec::<Raw<AnySyncEphemeralRoomEvent>>::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let typings = services
|
let typings = typings_event_for_user(services, room_id, sender_user).await?;
|
||||||
.rooms
|
|
||||||
.typing
|
|
||||||
.typings_event_for_user(room_id, sender_user)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(vec![serde_json::from_str(&serde_json::to_string(&typings)?)?])
|
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.push(user_id.to_owned());
|
||||||
heroes
|
heroes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn typings_event_for_user(
|
||||||
|
services: &Services,
|
||||||
|
room_id: &RoomId,
|
||||||
|
sender_user: &UserId,
|
||||||
|
) -> Result<SyncEphemeralRoomEvent<TypingEventContent>> {
|
||||||
|
Ok(SyncEphemeralRoomEvent {
|
||||||
|
content: TypingEventContent {
|
||||||
|
user_ids: services
|
||||||
|
.rooms
|
||||||
|
.typing
|
||||||
|
.typing_users_for_user(room_id, sender_user)
|
||||||
|
.await?,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use futures::StreamExt;
|
|||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedRoomId, OwnedUserId, RoomId, UserId,
|
OwnedRoomId, OwnedUserId, RoomId, UserId,
|
||||||
api::federation::transactions::edu::{Edu, TypingContent},
|
api::federation::transactions::edu::{Edu, TypingContent},
|
||||||
events::SyncEphemeralRoomEvent,
|
|
||||||
};
|
};
|
||||||
use tokio::sync::{RwLock, broadcast};
|
use tokio::sync::{RwLock, broadcast};
|
||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
@@ -223,20 +222,6 @@ impl Service {
|
|||||||
Ok(user_ids)
|
Ok(user_ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn typings_event_for_user(
|
|
||||||
&self,
|
|
||||||
room_id: &RoomId,
|
|
||||||
sender_user: &UserId,
|
|
||||||
) -> Result<SyncEphemeralRoomEvent<ruma::events::typing::TypingEventContent>> {
|
|
||||||
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 {
|
async fn federation_send(&self, room_id: &RoomId, user_id: &UserId, typing: bool) -> Result {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
self.services.globals.user_is_local(user_id),
|
self.services.globals.user_is_local(user_id),
|
||||||
|
|||||||
Reference in New Issue
Block a user