Add is_direct() query for account_data.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk committed 2025-10-08 03:33:12 +00:00
1 parent 4ca68deef8
commit 51fc2342a4
2 files changed
+20

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
use ruma::{
RoomId, UserId,
events::{GlobalAccountDataEventType, direct::DirectEventContent},
};
use tuwunel_core::{at, implement, is_equal_to};
#[implement(super::Service)]
pub async fn is_direct(&self, user_id: &UserId, room_id: &RoomId) -> bool {
self.services
.account_data
.get_global(user_id, GlobalAccountDataEventType::Direct)
.await
.map(|content: DirectEventContent| content)
.into_iter()
.flat_map(DirectEventContent::into_iter)
.map(at!(1))
.flat_map(Vec::into_iter)
.any(is_equal_to!(room_id))
}
+1
View File
@@ -1,3 +1,4 @@
mod direct;
mod room_tags;
use std::sync::Arc;