From a7966b8f05474bfc41510ec9713f092d17d9fc21 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 17 Mar 2024 12:16:04 -0400 Subject: [PATCH] config option to allow incoming remote read receipts Signed-off-by: strawberry --- conduwuit-example.toml | 5 ++++- src/api/server_server.rs | 4 ++++ src/config/mod.rs | 7 +++++++ src/service/globals/mod.rs | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 3fdf279d..089088f4 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -357,7 +357,7 @@ url_preview_check_root_domain = false -### Presence +### Presence / Typing Indicators / Read Receipts # Config option to control local (your server only) presence updates/requests. Defaults to false. # Note that presence on conduwuit is very fast unlike Synapse's. @@ -385,6 +385,9 @@ url_preview_check_root_domain = false # Config option to control how many seconds before presence updates that you are offline. Defaults to 30 minutes. #presence_offline_timeout_s = 1800 +# Config option to control whether we should receive remote incoming read receipts. +# Defaults to true. +#allow_incoming_read_receipts = true # Other options not in [global]: diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 07be27f4..a2395526 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -823,6 +823,10 @@ pub async fn send_transaction_message_route( } }, Edu::Receipt(receipt) => { + if !services().globals.allow_incoming_read_receipts() { + continue; + } + for (room_id, room_updates) in receipt.receipts { for (user_id, user_updates) in room_updates.read { if let Some((event_id, _)) = user_updates diff --git a/src/config/mod.rs b/src/config/mod.rs index 19731bbe..c6252a83 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -144,6 +144,9 @@ pub struct Config { #[serde(default = "default_presence_offline_timeout_s")] pub presence_offline_timeout_s: u64, + #[serde(default = "true_fn")] + pub allow_incoming_read_receipts: bool, + #[serde(default)] pub zstd_compression: bool, @@ -282,6 +285,10 @@ impl fmt::Display for Config { "Allow local presence requests (updates)", &self.allow_local_presence.to_string(), ), + ( + "Allow incoming remote read receipts", + &self.allow_incoming_read_receipts.to_string(), + ), ( "Block non-admin room invites (local and remote, admins can still send and receive invites)", &self.block_non_admin_invites.to_string(), diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index f54f0686..6f30e1b2 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -359,6 +359,8 @@ impl Service<'_> { pub fn presence_offline_timeout_s(&self) -> u64 { self.config.presence_offline_timeout_s } + pub fn allow_incoming_read_receipts(&self) -> bool { self.config.allow_incoming_read_receipts } + pub fn rocksdb_log_level(&self) -> &String { &self.config.rocksdb_log_level } pub fn rocksdb_max_log_file_size(&self) -> usize { self.config.rocksdb_max_log_file_size }