From d715ab7f5edd1dd45df67f18f290c05f70419dde Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 12 May 2024 17:33:25 -0400 Subject: [PATCH] disable URL previews by default upon admin room creation Signed-off-by: strawberry --- Cargo.lock | 24 ++++++++++++------------ src/service/admin/mod.rs | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73209431..d44a731e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2723,7 +2723,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.10.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "assign", "js_int", @@ -2743,7 +2743,7 @@ dependencies = [ [[package]] name = "ruma-appservice-api" version = "0.10.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "js_int", "ruma-common", @@ -2755,7 +2755,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.18.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "as_variant", "assign", @@ -2777,7 +2777,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.13.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "as_variant", "base64 0.22.1", @@ -2807,7 +2807,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.28.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "as_variant", "indexmap 2.2.6", @@ -2829,7 +2829,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.9.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "js_int", "ruma-common", @@ -2841,7 +2841,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.9.5" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "js_int", "thiserror", @@ -2850,7 +2850,7 @@ dependencies = [ [[package]] name = "ruma-identity-service-api" version = "0.9.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "js_int", "ruma-common", @@ -2860,7 +2860,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.13.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "once_cell", "proc-macro-crate", @@ -2875,7 +2875,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.9.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "js_int", "ruma-common", @@ -2887,7 +2887,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.15.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "base64 0.22.1", "ed25519-dalek", @@ -2903,7 +2903,7 @@ dependencies = [ [[package]] name = "ruma-state-res" version = "0.11.0" -source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#9e29e07ae1561fa7e6ed1897192f9c43c111b026" +source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#62aca1e976d0c161d5b2c413bde6d0079f75f3ee" dependencies = [ "itertools", "js_int", diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 8907869e..56a08a39 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -16,6 +16,7 @@ use ruma::{ message::{Relation::Reply, RoomMessageEventContent}, name::RoomNameEventContent, power_levels::RoomPowerLevelsEventContent, + preview_url::RoomPreviewUrlsEventContent, topic::RoomTopicEventContent, }, TimelineEventType, @@ -634,6 +635,27 @@ impl Service { services().rooms.alias.set_alias(&alias, &room_id)?; + // 7. (ad-hoc) Disable room previews for everyone by default + services() + .rooms + .timeline + .build_and_append_pdu( + PduBuilder { + event_type: TimelineEventType::RoomPreviewUrls, + content: to_raw_value(&RoomPreviewUrlsEventContent { + disabled: true, + }) + .expect("event is valid we just created it"), + unsigned: None, + state_key: Some(String::new()), + redacts: None, + }, + &server_user, + &room_id, + &state_lock, + ) + .await?; + Ok(()) }