feat: Add config option for receiving read receipts

Adds an option for ignoring incoming read receipts over federation
This commit is contained in:
Nyaaori 2022-11-26 15:01:12 +01:00
parent ccc5030896
commit 9d4f2884e1
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
3 changed files with 43 additions and 35 deletions

View file

@ -746,6 +746,7 @@ pub async fn send_transaction_message_route(
match edu { match edu {
Edu::Presence(_) => {} Edu::Presence(_) => {}
Edu::Receipt(receipt) => { Edu::Receipt(receipt) => {
if services().globals.allow_receiving_read_receipts() {
for (room_id, room_updates) in receipt.receipts { for (room_id, room_updates) in receipt.receipts {
for (user_id, user_updates) in room_updates.read { for (user_id, user_updates) in room_updates.read {
if let Some((event_id, _)) = user_updates if let Some((event_id, _)) = user_updates
@ -787,6 +788,7 @@ pub async fn send_transaction_message_route(
} }
} }
} }
}
Edu::Typing(typing) => { Edu::Typing(typing) => {
if services() if services()
.rooms .rooms

View file

@ -49,6 +49,8 @@ pub struct Config {
#[serde(default = "true_fn")] #[serde(default = "true_fn")]
pub allow_public_read_receipts: bool, pub allow_public_read_receipts: bool,
#[serde(default = "true_fn")] #[serde(default = "true_fn")]
pub allow_receiving_read_receipts: bool,
#[serde(default = "true_fn")]
pub allow_room_creation: bool, pub allow_room_creation: bool,
#[serde(default = "true_fn")] #[serde(default = "true_fn")]
pub allow_unstable_room_versions: bool, pub allow_unstable_room_versions: bool,

View file

@ -238,6 +238,10 @@ impl Service {
self.config.allow_public_read_receipts self.config.allow_public_read_receipts
} }
pub fn allow_receiving_read_receipts(&self) -> bool {
self.config.allow_receiving_read_receipts
}
pub fn allow_room_creation(&self) -> bool { pub fn allow_room_creation(&self) -> bool {
self.config.allow_room_creation self.config.allow_room_creation
} }