base: Fetch the member presence when we fetch members.
parent
38048a2043
commit
b4d0179c18
|
@ -175,10 +175,15 @@ impl Room {
|
||||||
let invited = self.store.get_invited_user_ids(self.room_id()).await;
|
let invited = self.store.get_invited_user_ids(self.room_id()).await;
|
||||||
|
|
||||||
let x = move |u| async move {
|
let x = move |u| async move {
|
||||||
|
let presence = self.store.get_presence_event(&u).await;
|
||||||
|
|
||||||
self.store
|
self.store
|
||||||
.get_member_event(self.room_id(), &u)
|
.get_member_event(self.room_id(), &u)
|
||||||
.await
|
.await
|
||||||
.map(|m| m.into())
|
.map(|m| RoomMember {
|
||||||
|
event: m.into(),
|
||||||
|
presence: presence.into(),
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
joined.chain(invited).filter_map(x)
|
joined.chain(invited).filter_map(x)
|
||||||
|
@ -294,10 +299,15 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_member(&self, user_id: &UserId) -> Option<RoomMember> {
|
pub async fn get_member(&self, user_id: &UserId) -> Option<RoomMember> {
|
||||||
|
let presence = self.store.get_presence_event(user_id).await;
|
||||||
|
|
||||||
self.store
|
self.store
|
||||||
.get_member_event(&self.room_id, user_id)
|
.get_member_event(&self.room_id, user_id)
|
||||||
.await
|
.await
|
||||||
.map(|e| e.into())
|
.map(|e| RoomMember {
|
||||||
|
event: e.into(),
|
||||||
|
presence: presence.into(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn room_id(&self) -> &RoomId {
|
pub fn room_id(&self) -> &RoomId {
|
||||||
|
@ -316,6 +326,7 @@ impl Room {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RoomMember {
|
pub struct RoomMember {
|
||||||
event: Arc<SyncStateEvent<MemberEventContent>>,
|
event: Arc<SyncStateEvent<MemberEventContent>>,
|
||||||
|
presence: Arc<Option<PresenceEvent>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RoomMember {
|
impl RoomMember {
|
||||||
|
@ -340,14 +351,6 @@ impl RoomMember {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SyncStateEvent<MemberEventContent>> for RoomMember {
|
|
||||||
fn from(event: SyncStateEvent<MemberEventContent>) -> Self {
|
|
||||||
Self {
|
|
||||||
event: Arc::new(event),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct InnerSummary {
|
pub struct InnerSummary {
|
||||||
room_id: Arc<RoomId>,
|
room_id: Arc<RoomId>,
|
||||||
|
@ -577,6 +580,13 @@ impl Store {
|
||||||
self.inner.flush_async().await.unwrap();
|
self.inner.flush_async().await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_presence_event(&self, user_id: &UserId) -> Option<PresenceEvent> {
|
||||||
|
self.presence
|
||||||
|
.get(user_id.as_bytes())
|
||||||
|
.unwrap()
|
||||||
|
.map(|e| serde_json::from_slice(&e).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_member_event(
|
pub async fn get_member_event(
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
|
|
Loading…
Reference in New Issue