From 68f42f5a2fc0a5e84c59aa7a72dbe7855ea2de27 Mon Sep 17 00:00:00 2001 From: strawberry Date: Tue, 28 May 2024 15:07:30 -0400 Subject: [PATCH] fed: relax read receipt EDU check so in theory: guest users, peaking over federation, and world readable rooms should be allowed to send read receipts even if they're not joined. relaxing this check to only allow the read receipt if the server has at least 1 member in the room makes some of this still work Signed-off-by: strawberry --- src/api/server_server.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 1fe1ed1b..7eb4d7cf 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -367,7 +367,13 @@ pub(crate) async fn send_transaction_message_route( continue; } - if services().rooms.state_cache.is_joined(&user_id, &room_id)? { + if services() + .rooms + .state_cache + .room_members(&room_id) + .filter_map(Result::ok) + .any(|member| member.server_name() == user_id.server_name()) + { for event_id in &user_updates.event_ids { let mut user_receipts = BTreeMap::new(); user_receipts.insert(user_id.clone(), user_updates.data.clone()); @@ -389,7 +395,7 @@ pub(crate) async fn send_transaction_message_route( .readreceipt_update(&user_id, &room_id, event)?; } } else { - debug_warn!(%user_id, %room_id, "received read receipt EDU for user not in room"); + debug_warn!(%user_id, %room_id, %origin, "received read receipt EDU from server who does not have a single member from their server in the room"); continue; } } @@ -411,7 +417,7 @@ pub(crate) async fn send_transaction_message_route( .acl_check(typing.user_id.server_name(), &typing.room_id) .is_err() { - debug_warn!(%typing.user_id, %typing.room_id, "received typing EDU for ACL'd user's server"); + debug_warn!(%typing.user_id, %typing.room_id, %origin, "received typing EDU for ACL'd user's server"); continue; } @@ -441,7 +447,7 @@ pub(crate) async fn send_transaction_message_route( .await?; } } else { - debug_warn!(%typing.user_id, %typing.room_id, "received typing EDU for user not in room"); + debug_warn!(%typing.user_id, %typing.room_id, %origin, "received typing EDU for user not in room"); continue; } },